git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v6 0/7] strbuf cleanups

From
Calvin Wan <calvinwan@google.com>
Date
May 12, 2023, 17:14 UTC
Message-ID
<20230512171429.2202982-1-calvinwan@google.com>
In-Reply-To
<20230511194446.1492907-1-calvinwan@google.com>

Reroll with last couple of nits fixed. Thanks again to everyone for reviewing this series!

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 global variable
 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                   | 112 ++++---------------------------------
 strbuf.h                   |  57 ++++++-------------
 tempfile.c                 |   1 +
 wt-status.c                |   6 +-
 26 files changed, 227 insertions(+), 192 deletions(-)
Range-diff against v5:
1:  287e787c9c ! 1:  5ae531a1e2 strbuf: clarify API boundary
    @@ strbuf.h
     +/*
     + * NOTE FOR STRBUF DEVELOPERS
     + *
    -+ * The objects that this API interacts with should be limited to other
    -+ * primitives, however, there are older functions in here that interact
    -+ * with non-primitive objects which should eventually be moved out or
    -+ * refactored.
    ++ * strbuf is a low-level primitive; as such it should interact only
    ++ * with other low-level primitives. Do not introduce new functions
    ++ * which interact with higher-level APIs.
     + */
     +
      struct string_list;
2:  5bd27cad7a = 2:  3bb2b9c01a abspath: move related functions to abspath
3:  08e3e40de6 = 3:  ff91ca2fda credential-store: move related functions to credential-store file
4:  1a21d4fdd1 = 4:  10e61eb570 object-name: move related functions to object-name
5:  03b20f3384 = 5:  c3d5db4e11 path: move related function to path
6:  b55f4a39e1 = 6:  113d156195 strbuf: clarify dependency
7:  6ea36d7730 ! 7:  01c923160d strbuf: remove global variable
    @@ Commit message
         functions. Therefore, add an additional parameter for functions that use
         comment_line_char and refactor callers to pass it in instead.
         strbuf_stripspace() removes the skip_comments boolean and checks if
    -    comment_line_char is a non-NULL character to determine whether to skip
    +    comment_line_char is a non-NUL character to determine whether to skip
         comments or not.
     
      ## add-patch.c ##
    @@ strbuf.c: static size_t cleanup(char *line, size_t len)
       *
     - * Enable skip_comments to skip every line starting with comment
     - * character.
    -+ * Pass a non-NULL comment_line_char to skip every line starting
    -+ * with it
    ++ * Pass a non-NUL comment_line_char to skip every line starting
    ++ * with it.
       */
     -void strbuf_stripspace(struct strbuf *sb, int skip_comments)
     +void strbuf_stripspace(struct strbuf *sb, char comment_line_char)
    @@ strbuf.c: void strbuf_stripspace(struct strbuf *sb, int skip_comments)
      		len = eol ? eol - (sb->buf + i) + 1 : sb->len - i;
      
     -		if (skip_comments && len && sb->buf[i] == comment_line_char) {
    -+		if (comment_line_char != '\0' && len &&
    ++		if (comment_line_char && len &&
     +		    sb->buf[i] == comment_line_char) {
      			newlen = 0;
      			continue;
    @@ strbuf.h: int strbuf_getcwd(struct strbuf *sb);
      /**
     - * Strip whitespace from a buffer. The second parameter controls if
     - * comments are considered contents to be removed or not.
    -+ * Strip whitespace from a buffer. The second parameter is the comment
    -+ * character that determines whether a line is a comment or not. If the
    -+ * second parameter is a non-NULL character, comments are considered
    -+ * contents to be removed.
    ++ * Strip whitespace from a buffer. If comment_line_char is non-NUL,
    ++ * then lines beginning with that character are considered comments,
    ++ * thus removed.
       */
     -void strbuf_stripspace(struct strbuf *buf, int skip_comments);
     +void strbuf_stripspace(struct strbuf *buf, char comment_line_char);
-- 
2.40.1.606.ga4b1b128d6-goog
Previous: Junio C HamanoNext: Calvin Wan
Message 68 of 85 in “strbuf cleanups”
  1. 0/6 strbuf cleanupsCalvin Wan, May 2, 2023
  2. 1/6 abspath: move related functions to abspathCalvin Wan, May 2, 2023
  3. Junio C HamanoMay 2, 2023
  4. 2/6 credential-store: move related functions to credential-store fileCalvin Wan, May 2, 2023
  5. Junio C HamanoMay 2, 2023
  6. Jeff KingMay 3, 2023
  7. Jeff KingMay 3, 2023
  8. Calvin WanMay 3, 2023
  9. 3/6 object-name: move related functions to object-nameCalvin Wan, May 2, 2023
  10. 4/6 path: move related function to pathCalvin Wan, May 2, 2023
  11. 5/6 strbuf: clarify dependencyCalvin Wan, May 2, 2023
  12. Elijah NewrenMay 3, 2023
  13. 6/6 strbuf: remove environment variablesCalvin Wan, May 2, 2023
  14. Elijah NewrenMay 3, 2023
  15. Junio C HamanoMay 2, 2023
  16. Junio C HamanoMay 2, 2023
  17. Felipe ContrerasMay 2, 2023
  18. Calvin WanMay 2, 2023
  19. Elijah NewrenMay 3, 2023
  20. Calvin WanMay 3, 2023
  21. Elijah NewrenMay 7, 2023
  22. Jeff KingMay 7, 2023
  23. 0/7 strbuf cleanupsCalvin Wan, May 3, 2023
  24. 1/7 strbuf: clarify API boundaryCalvin Wan, May 3, 2023
  25. 2/7 abspath: move related functions to abspathCalvin Wan, May 3, 2023
  26. 3/7 credential-store: move related functions to credential-store fileCalvin Wan, May 3, 2023
  27. 5/7 path: move related function to pathCalvin Wan, May 3, 2023
  28. 4/7 object-name: move related functions to object-nameCalvin Wan, May 3, 2023
  29. 6/7 strbuf: clarify dependencyCalvin Wan, May 3, 2023
  30. Junio C HamanoMay 3, 2023
  31. 7/7 strbuf: remove environment variablesCalvin Wan, May 3, 2023
  32. Junio C HamanoMay 3, 2023
  33. Calvin WanMay 3, 2023
  34. Junio C HamanoMay 3, 2023
  35. 7/7 strbuf: remove environment variableCalvin Wan, May 3, 2023
  36. Junio C HamanoMay 5, 2023
  37. Calvin WanMay 8, 2023
  38. Elijah NewrenMay 7, 2023
  39. Felipe ContrerasMay 7, 2023
  40. 0/7 strbuf cleanupsCalvin Wan, May 8, 2023
  41. 1/7 strbuf: clarify API boundaryCalvin Wan, May 8, 2023
  42. Eric SunshineMay 8, 2023
  43. Junio C HamanoMay 10, 2023
  44. 3/7 credential-store: move related functions to credential-store fileCalvin Wan, May 8, 2023
  45. 5/7 path: move related function to pathCalvin Wan, May 8, 2023
  46. 2/7 abspath: move related functions to abspathCalvin Wan, May 8, 2023
  47. 4/7 object-name: move related functions to object-nameCalvin Wan, May 8, 2023
  48. 6/7 strbuf: clarify dependencyCalvin Wan, May 8, 2023
  49. 7/7 strbuf: remove global variableCalvin Wan, May 8, 2023
  50. Phillip WoodMay 10, 2023
  51. Elijah NewrenMay 9, 2023
  52. Felipe ContrerasMay 9, 2023
  53. 0/7 strbuf cleanupsCalvin Wan, May 11, 2023
  54. 1/7 strbuf: clarify API boundaryCalvin Wan, May 11, 2023
  55. Eric SunshineMay 11, 2023
  56. Calvin WanMay 11, 2023
  57. 2/7 abspath: move related functions to abspathCalvin Wan, May 11, 2023
  58. 3/7 credential-store: move related functions to credential-store fileCalvin Wan, May 11, 2023
  59. 6/7 strbuf: clarify dependencyCalvin Wan, May 11, 2023
  60. 5/7 path: move related function to pathCalvin Wan, May 11, 2023
  61. 4/7 object-name: move related functions to object-nameCalvin Wan, May 11, 2023
  62. 7/7 strbuf: remove global variableCalvin Wan, May 11, 2023
  63. Eric SunshineMay 11, 2023
  64. Junio C HamanoMay 11, 2023
  65. Phillip WoodMay 12, 2023
  66. Phillip WoodMay 12, 2023
  67. Junio C HamanoMay 12, 2023
  68. 0/7 strbuf cleanupsCalvin Wan, May 12, 2023
  69. 1/7 strbuf: clarify API boundaryCalvin Wan, May 12, 2023
  70. 2/7 abspath: move related functions to abspathCalvin Wan, May 12, 2023
  71. 4/7 object-name: move related functions to object-nameCalvin Wan, May 12, 2023
  72. 3/7 credential-store: move related functions to credential-store fileCalvin Wan, May 12, 2023
  73. 5/7 path: move related function to pathCalvin Wan, May 12, 2023
  74. 6/7 strbuf: clarify dependencyCalvin Wan, May 12, 2023
  75. 7/7 strbuf: remove global variableCalvin Wan, May 12, 2023
  76. Junio C HamanoMay 12, 2023
  77. Eric SunshineMay 13, 2023
  78. 0/7 strbuf cleanupsCalvin Wan, Jun 6, 2023
  79. 1/7 strbuf: clarify API boundaryCalvin Wan, Jun 6, 2023
  80. 2/7 strbuf: clarify dependencyCalvin Wan, Jun 6, 2023
  81. 6/7 path: move related function to pathCalvin Wan, Jun 6, 2023
  82. 3/7 abspath: move related functions to abspathCalvin Wan, Jun 6, 2023
  83. 5/7 object-name: move related functions to object-nameCalvin Wan, Jun 6, 2023
  84. 4/7 credential-store: move related functions to credential-store fileCalvin Wan, Jun 6, 2023
  85. 7/7 strbuf: remove global variableCalvin Wan, Jun 6, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.