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

Re: [PATCH v2 0/7] strbuf cleanups

From
Elijah Newren <newren@gmail.com>
Date
May 7, 2023, 00:40 UTC
Message-ID
<CABPp-BGk-s+4b+OHi9FDXjwz5BeZPS8qb4XiJ8CVwkt8Siaq8A@mail.gmail.com>
In-Reply-To
<20230503184849.1809304-1-calvinwan@google.com>
On Wed, May 3, 2023 at 11:48 AM Calvin Wan <calvinwan@google.com> wrote:
>
> Strbuf is a widely used basic structure that should only interact with
> other primitives in strbuf.[ch].

"should"? I agree with moving things in this direction, but the wording here suggests there's a pre-existing directive or guideline; but if so, I'm unfamiliar with it. Maybe this should be reworded to "This series modifies strbuf to focus on string manipulation with minimal other dependencies"?

Show 7 quoted lines
> 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.
As Junio pointed out, "environment variables" is misleading; see below.
> Range-diff against v1:
> -:  ---------- > 1:  e0dd3f5295 strbuf: clarify API boundary
I read this separately; this patch looks good to me.
Show 8 quoted lines
> 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.
This applies to patches 4 & 5 as well:
Would this perhaps be better worded as:
    Move abspath-related functions from strbuf.[ch] to abspath.[ch] so that
    strbuf is focused on string manipulation routines with minimal dependencies.
?
Show 37 quoted lines
>       ## 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.
>     +
Thanks.
Show 17 quoted lines
> 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.

"environment variable" makes one think not of "variable from environment.c [that happens to be a global]" but of https://en.wikipedia.org/wiki/Environment_variable. The fact that the variable is defined in environment.c isn't even relevant here, though, while the fact that it is a global is relevant. I'd just s/environment variable/global variable/ in all 4 places (er, 5 if you include the cover letter).

Your v3 7/7 has an important correction, but you didn't send out a range diff for v3 so I'm putting my comments on your v2 range-diff. :-)

Show 7 quoted lines
>     + /**
>        * 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.
>        */
Thanks.

This series fixes two of my comments on v1, and the other was just "here's another cleanup that could be added" -- it's fine to punt on.

I only had a couple minor comments on this v2/v3 that should be easy to fix up, all included in this response to the cover letter.

Previous: Calvin WanNext: Felipe Contreras
Message 38 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.