Git Mailing List Archive mirror
 help / color / mirror / Atom feed
From: Calvin Wan <calvinwan@google.com>
To: git@vger.kernel.org
Cc: Calvin Wan <calvinwan@google.com>, newren@gmail.com, peff@peff.net
Subject: [PATCH v2 0/7] strbuf cleanups
Date: Wed,  3 May 2023 18:48:49 +0000	[thread overview]
Message-ID: <20230503184849.1809304-1-calvinwan@google.com> (raw)
In-Reply-To: <20230502211454.1673000-1-calvinwan@google.com>

Strbuf is a widely used basic structure that should only interact with
other primitives in strbuf.[ch]. Over time certain functions inside of
strbuf.[ch] have been added to interact with higher level objects and
functions. This series cleans up some of those higher level interactions
by moving the offending functions to the files they interact with and
adding documentation to strbuf.h. With the goal of eventually being able
to stand up strbuf as a libary, this series also removes the use of
environment variables from strbuf.

Calvin Wan (7):
  strbuf: clarify API boundary
  abspath: move related functions to abspath
  credential-store: move related functions to credential-store file
  object-name: move related functions to object-name
  path: move related function to path
  strbuf: clarify dependency
  strbuf: remove environment variables

 abspath.c                  |  36 +++++++++++++
 abspath.h                  |  21 ++++++++
 add-patch.c                |  12 +++--
 builtin/am.c               |   2 +-
 builtin/branch.c           |   4 +-
 builtin/commit.c           |   2 +-
 builtin/credential-store.c |  19 +++++++
 builtin/merge.c            |  10 ++--
 builtin/notes.c            |  16 +++---
 builtin/rebase.c           |   2 +-
 builtin/stripspace.c       |   6 ++-
 builtin/tag.c              |   9 ++--
 fmt-merge-msg.c            |   9 ++--
 gpg-interface.c            |   5 +-
 hook.c                     |   1 +
 object-name.c              |  15 ++++++
 object-name.h              |   9 ++++
 path.c                     |  20 +++++++
 path.h                     |   5 ++
 pretty.c                   |   1 +
 rebase-interactive.c       |  15 +++---
 sequencer.c                |  24 +++++----
 strbuf.c                   | 106 +++----------------------------------
 strbuf.h                   |  53 +++++--------------
 tempfile.c                 |   1 +
 wt-status.c                |   6 +--
 26 files changed, 220 insertions(+), 189 deletions(-)

Range-diff against v1:
-:  ---------- > 1:  e0dd3f5295 strbuf: clarify API boundary
1:  283771c088 ! 2:  ec1ea6ae4f abspath: move related functions to abspath
    @@ Commit message
         abspath: move related functions to abspath
     
         Move abspath-related functions from strbuf.[ch] to abspath.[ch] since
    -    they do not belong in a low-level library.
    +    paths are not primitive objects and therefore strbuf should not interact
    +    with them.
     
      ## abspath.c ##
     @@ abspath.c: char *prefix_filename_except_for_dash(const char *pfx, const char *arg)
2:  58f78b8ae0 = 3:  2d74561b91 credential-store: move related functions to credential-store file
3:  88ab90c079 ! 4:  30b5e635cb object-name: move related functions to object-name
    @@ Commit message
         object-name: move related functions to object-name
     
         Move object-name-related functions from strbuf.[ch] to object-name.[ch]
    -    since they do not belong in a low-level library.
    +    since paths are not a primitive object that strbuf should directly
    +    interact with.
     
      ## object-name.c ##
     @@ object-name.c: static void find_abbrev_len_packed(struct min_abbrev_data *mad)
4:  30b7de5a81 ! 5:  6905618470 path: move related function to path
    @@ Metadata
      ## Commit message ##
         path: move related function to path
     
    -    Move path-related function from strbuf.[ch] to path.[ch] since it does
    -    not belong in a low-level library.
    +    Move path-related function from strbuf.[ch] to path.[ch] since path is
    +    not a primitive object and therefore strbuf should not directly interact
    +    with it.
     
      ## path.c ##
     @@ path.c: int normalize_path_copy(char *dst, const char *src)
5:  7b6d6353de ! 6:  caf3482bf7 strbuf: clarify dependency
    @@ Metadata
      ## Commit message ##
         strbuf: clarify dependency
     
    +    refs.h was once needed but is no longer so as of 6bab74e7fb8 ("strbuf:
    +    move strbuf_branchname to sha1_name.c", 2010-11-06). strbuf.h was
    +    included thru refs.h, so removing refs.h requires strbuf.h to be added
    +    back.
    +
      ## strbuf.c ##
     @@
      #include "environment.h"
6:  ffacd1cbe5 ! 7:  a7f23488f8 strbuf: remove enviroment variables
    @@ Metadata
     Author: Calvin Wan <calvinwan@google.com>
     
      ## Commit message ##
    -    strbuf: remove enviroment variables
    +    strbuf: remove environment variables
     
    -    As a lower level library, strbuf should not directly access environment
    -    variables within its functions. Therefore, add an additional variable to
    -    function signatures for functions that use an environment variable and
    -    refactor callers to pass in the environment variable.
    +    As a library that only interacts with other primitives, strbuf should
    +    not directly access environment variables within its
    +    functions. Therefore, add an additional variable to function signatures
    +    for functions that use an environment variable and refactor callers to
    +    pass in the environment variable.
     
      ## add-patch.c ##
     @@ add-patch.c: static int edit_hunk_manually(struct add_p_state *s, struct hunk *hunk)
    @@ strbuf.h: void strbuf_addf(struct strbuf *sb, const char *fmt, ...);
      __attribute__((format (printf,2,0)))
      void strbuf_vaddf(struct strbuf *sb, const char *fmt, va_list ap);
     @@ strbuf.h: int strbuf_normalize_path(struct strbuf *sb);
    + 
    + /**
       * Strip whitespace from a buffer. The second parameter controls if
    -  * comments are considered contents to be removed or not.
    +- * comments are considered contents to be removed or not.
    ++ * comments are considered contents to be removed or not. The third parameter
    ++ * is the comment character that determines whether a line is a comment or not.
       */
     -void strbuf_stripspace(struct strbuf *buf, int skip_comments);
     +void strbuf_stripspace(struct strbuf *buf, int skip_comments, char comment_line_char);
-- 
2.40.1.521.gf1e218fcd8-goog


  parent reply	other threads:[~2023-05-03 18:49 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-02 21:14 [PATCH 0/6] strbuf cleanups Calvin Wan
2023-05-02 21:14 ` [PATCH 1/6] abspath: move related functions to abspath Calvin Wan
2023-05-02 21:42   ` Junio C Hamano
2023-05-02 21:14 ` [PATCH 2/6] credential-store: move related functions to credential-store file Calvin Wan
2023-05-02 21:52   ` Junio C Hamano
2023-05-03 16:28   ` Jeff King
2023-05-03 16:34     ` Jeff King
2023-05-03 18:38       ` Calvin Wan
2023-05-02 21:14 ` [PATCH 3/6] object-name: move related functions to object-name Calvin Wan
2023-05-02 21:14 ` [PATCH 4/6] path: move related function to path Calvin Wan
2023-05-02 21:14 ` [PATCH 5/6] strbuf: clarify dependency Calvin Wan
2023-05-03  1:56   ` Elijah Newren
2023-05-02 21:14 ` [PATCH 6/6] strbuf: remove environment variables Calvin Wan
2023-05-03  2:15   ` Elijah Newren
2023-05-02 22:20 ` [PATCH 0/6] strbuf cleanups Junio C Hamano
2023-05-02 22:31   ` Junio C Hamano
2023-05-02 23:51     ` Felipe Contreras
2023-05-02 22:36   ` Calvin Wan
2023-05-03  2:37 ` Elijah Newren
2023-05-03 18:00   ` Calvin Wan
2023-05-07  0:14     ` Elijah Newren
2023-05-07 13:14       ` Jeff King
2023-05-03 18:48 ` Calvin Wan [this message]
2023-05-03 18:50   ` [PATCH v2 1/7] strbuf: clarify API boundary Calvin Wan
2023-05-03 18:50   ` [PATCH v2 2/7] abspath: move related functions to abspath Calvin Wan
2023-05-03 18:50   ` [PATCH v2 3/7] credential-store: move related functions to credential-store file Calvin Wan
2023-05-03 18:50   ` [PATCH v2 4/7] object-name: move related functions to object-name Calvin Wan
2023-05-03 18:50   ` [PATCH v2 5/7] path: move related function to path Calvin Wan
2023-05-03 18:50   ` [PATCH v2 6/7] strbuf: clarify dependency Calvin Wan
2023-05-03 19:26     ` Junio C Hamano
2023-05-03 18:50   ` [PATCH v2 7/7] strbuf: remove environment variables Calvin Wan
2023-05-03 19:24     ` Junio C Hamano
2023-05-03 19:41       ` Calvin Wan
2023-05-03 19:45         ` Junio C Hamano
2023-05-03 19:42     ` [PATCH v3 7/7] strbuf: remove environment variable Calvin Wan
2023-05-05 22:33   ` [PATCH v2 0/7] strbuf cleanups Junio C Hamano
2023-05-08 16:38     ` Calvin Wan
2023-05-07  0:40   ` Elijah Newren
2023-05-07 21:47     ` Felipe Contreras
2023-05-08 16:57   ` [PATCH v4 " Calvin Wan
2023-05-08 16:59     ` [PATCH v4 1/7] strbuf: clarify API boundary Calvin Wan
2023-05-08 17:22       ` Eric Sunshine
2023-05-10 22:51         ` Junio C Hamano
2023-05-08 16:59     ` [PATCH v4 2/7] abspath: move related functions to abspath Calvin Wan
2023-05-08 16:59     ` [PATCH v4 3/7] credential-store: move related functions to credential-store file Calvin Wan
2023-05-08 16:59     ` [PATCH v4 4/7] object-name: move related functions to object-name Calvin Wan
2023-05-08 16:59     ` [PATCH v4 5/7] path: move related function to path Calvin Wan
2023-05-08 16:59     ` [PATCH v4 6/7] strbuf: clarify dependency Calvin Wan
2023-05-08 16:59     ` [PATCH v4 7/7] strbuf: remove global variable Calvin Wan
2023-05-10  8:12       ` Phillip Wood
2023-05-09  1:57     ` [PATCH v4 0/7] strbuf cleanups Elijah Newren
2023-05-09  2:13       ` Felipe Contreras
2023-05-11 19:44     ` [PATCH v5 " Calvin Wan
2023-05-11 19:48       ` [PATCH v5 1/7] strbuf: clarify API boundary Calvin Wan
2023-05-11 19:57         ` Eric Sunshine
2023-05-11 20:03           ` Calvin Wan
2023-05-11 19:48       ` [PATCH v5 2/7] abspath: move related functions to abspath Calvin Wan
2023-05-11 19:48       ` [PATCH v5 3/7] credential-store: move related functions to credential-store file Calvin Wan
2023-05-11 19:48       ` [PATCH v5 4/7] object-name: move related functions to object-name Calvin Wan
2023-05-11 19:48       ` [PATCH v5 5/7] path: move related function to path Calvin Wan
2023-05-11 19:48       ` [PATCH v5 6/7] strbuf: clarify dependency Calvin Wan
2023-05-11 19:48       ` [PATCH v5 7/7] strbuf: remove global variable Calvin Wan
2023-05-11 20:24         ` Eric Sunshine
2023-05-11 21:42         ` Junio C Hamano
2023-05-12 14:54           ` Phillip Wood
2023-05-12 14:53         ` Phillip Wood
2023-05-12 19:31           ` Junio C Hamano
2023-05-12 17:14       ` [PATCH v6 0/7] strbuf cleanups Calvin Wan
2023-05-12 17:15         ` [PATCH v6 1/7] strbuf: clarify API boundary Calvin Wan
2023-05-12 17:15         ` [PATCH v6 2/7] abspath: move related functions to abspath Calvin Wan
2023-05-12 17:15         ` [PATCH v6 3/7] credential-store: move related functions to credential-store file Calvin Wan
2023-05-12 17:15         ` [PATCH v6 4/7] object-name: move related functions to object-name Calvin Wan
2023-05-12 17:15         ` [PATCH v6 5/7] path: move related function to path Calvin Wan
2023-05-12 17:15         ` [PATCH v6 6/7] strbuf: clarify dependency Calvin Wan
2023-05-12 17:15         ` [PATCH v6 7/7] strbuf: remove global variable Calvin Wan
2023-05-12 20:24         ` [PATCH v6 0/7] strbuf cleanups Junio C Hamano
2023-05-13  5:54           ` Eric Sunshine
2023-06-06 19:47         ` [PATCH v7 " Calvin Wan
2023-06-06 19:48           ` [PATCH v7 1/7] strbuf: clarify API boundary Calvin Wan
2023-06-06 19:48           ` [PATCH v7 2/7] strbuf: clarify dependency Calvin Wan
2023-06-06 19:48           ` [PATCH v7 3/7] abspath: move related functions to abspath Calvin Wan
2023-06-06 19:48           ` [PATCH v7 4/7] credential-store: move related functions to credential-store file Calvin Wan
2023-06-06 19:48           ` [PATCH v7 5/7] object-name: move related functions to object-name Calvin Wan
2023-06-06 19:48           ` [PATCH v7 6/7] path: move related function to path Calvin Wan
2023-06-06 19:48           ` [PATCH v7 7/7] strbuf: remove global variable Calvin Wan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230503184849.1809304-1-calvinwan@google.com \
    --to=calvinwan@google.com \
    --cc=git@vger.kernel.org \
    --cc=newren@gmail.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).