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

[PATCH 0/2] config-parse: create config parsing library

From
Glen Choo via GitGitGadget <gitgitgadget@gmail.com>
Date
Jul 20, 2023, 22:17 UTC
Message-ID
<pull.1551.git.git.1689891436.gitgitgadget@gmail.com>

Config parsing no longer uses global state as of gc/config-context, so the natural next step for libification is to turn that into its own library. This series starts that process by moving config parsing into config-parse.[c|h] so that other programs can include this functionality without pulling in all of config.[c|h].

To use config-parse.[c|h], an external caller has to obey our convention of using "#include git-compat-util.h" at the start of the .c file. This is doable by including the in-tree git-compat-util.h and linking against the libgit.a Make target (which is admittedly cumbersome), and we've verified this by compiling and linking to the library using the Google-internal version of Bazel.

This series is not meant to distract from Calvin's git-std-lib series [1]. In fact, the two are complementary: git-std-lib will make it possible for external callers to compile a smaller subset of files in order to use a library. Doing this for config-parse will make config-parse easier to use, while testing that git-std-lib does what we want it to.

I considered calling the library config-ll (like we do in other parts of the codebase) instead of config-parse, with the intention of adding more "low level" config code to it in the future. A benefit to that is that by having fewer modules, dependency management is easier to reason about. However, I struggled to think of what other config code could be considered "low level" but doesn't make sense as its own module. (E.g. struct config_set is a low level implementation detail, but I think it's well-scoped enough to be its own config-set module.) I'd appreciate suggestions on how the config libraries could be organized.

[1] https://lore.kernel.org/git/20230627195251.1973421-1-calvinwan@google.com/

Glen Choo (2):
  config: return positive from git_config_parse_key()
  config-parse: split library out of config.[c|h]
 Makefile           |   1 +
 builtin/config.c   |   3 +-
 config-parse.c     | 611 +++++++++++++++++++++++++++++++++++++++++++
 config-parse.h     | 182 +++++++++++++
 config.c           | 636 +--------------------------------------------
 config.h           | 146 +----------
 submodule-config.c |   4 +-
 t/t1300-config.sh  |  16 ++
 8 files changed, 816 insertions(+), 783 deletions(-)
 create mode 100644 config-parse.c
 create mode 100644 config-parse.h
base-commit: aa9166bcc0ba654fc21f198a30647ec087f733ed
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1551%2Fchooglen%2Fconfig%2Fparse-lib-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1551/chooglen/config/parse-lib-v1
Pull-Request: https://github.com/git/git/pull/1551
-- 
gitgitgadget
Next: Glen Choo via GitGitGadget
Message 1 of 49 in “config-parse: create config parsing library”
  1. 0/2 config-parse: create config parsing libraryGlen Choo via GitGitGadget, Jul 20, 2023
  2. 1/2 config: return positive from git_config_parse_key()Glen Choo via GitGitGadget, Jul 20, 2023
  3. Jonathan TanJul 20, 2023
  4. Junio C HamanoJul 21, 2023
  5. Glen ChooJul 21, 2023
  6. Junio C HamanoJul 21, 2023
  7. 2/2 config-parse: split library out of config.[c|h]Glen Choo via GitGitGadget, Jul 20, 2023
  8. Jonathan TanJul 21, 2023
  9. Glen ChooJul 21, 2023
  10. 0/5 config-parse: create config parsing libraryGlen Choo, Jul 31, 2023
  11. 1/5 config: return positive from git_config_parse_key()Glen Choo, Jul 31, 2023
  12. 3/5 config: report config parse errors using cbGlen Choo, Jul 31, 2023
  13. Jonathan TanAug 4, 2023
  14. 2/5 config: split out config_parse_optionsGlen Choo, Jul 31, 2023
  15. 4/5 config.c: accept config_parse_options in git_config_from_stdinGlen Choo, Jul 31, 2023
  16. 5/5 config-parse: split library out of config.[c|h]Glen Choo, Jul 31, 2023
  17. 0/4 config-parse: create config parsing libraryJosh Steadmon, Aug 23, 2023
  18. 1/4 config: split out config_parse_optionsJosh Steadmon, Aug 23, 2023
  19. Junio C HamanoAug 23, 2023
  20. Josh SteadmonSep 21, 2023
  21. 3/4 config.c: accept config_parse_options in git_config_from_stdinJosh Steadmon, Aug 23, 2023
  22. 2/4 config: report config parse errors using cbJosh Steadmon, Aug 23, 2023
  23. Junio C HamanoAug 24, 2023
  24. Jonathan TanAug 24, 2023
  25. Junio C HamanoAug 24, 2023
  26. Josh SteadmonSep 21, 2023
  27. Junio C HamanoSep 21, 2023
  28. 4/4 config-parse: split library out of config.[c|h]Josh Steadmon, Aug 23, 2023
  29. Josh SteadmonAug 24, 2023
  30. 0/5 config-parse: create config parsing libraryJosh Steadmon, Sep 21, 2023
  31. 1/5 config: split out config_parse_optionsJosh Steadmon, Sep 21, 2023
  32. Jonathan TanOct 23, 2023
  33. Taylor BlauOct 23, 2023
  34. 5/5 config-parse: split library out of config.[c|h]Josh Steadmon, Sep 21, 2023
  35. Jonathan TanOct 23, 2023
  36. 2/5 config: split do_event() into start and flush operationsJosh Steadmon, Sep 21, 2023
  37. Jonathan TanOct 23, 2023
  38. 3/5 config: report config parse errors using cbJosh Steadmon, Sep 21, 2023
  39. Jonathan TanOct 23, 2023
  40. Taylor BlauOct 23, 2023
  41. Junio C HamanoOct 23, 2023
  42. 4/5 config.c: accept config_parse_options in git_config_from_stdinJosh Steadmon, Sep 21, 2023
  43. Jonathan TanOct 23, 2023
  44. Junio C HamanoOct 17, 2023
  45. Taylor BlauOct 23, 2023
  46. Junio C HamanoOct 23, 2023
  47. Jonathan TanOct 24, 2023
  48. Josh SteadmonOct 25, 2023
  49. Junio C HamanoOct 27, 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.