Skip to content

Commit

Permalink
config-parse: split library out of config.[c|h]
Browse files Browse the repository at this point in the history
The config parsing machinery (besides "include" directives) is usable by
programs other than Git - it works with works with any file written in
Git config syntax (IOW it doesn't rely on 'core' Git features like a
repository), and as of the series ending at 6e8e798 (config: pass
source to config_parser_event_fn_t, 2023-06-28), it no longer relies on
global state. Thus, we can and should start turning it into a library
other programs can use.

Begin this process by splitting the config parsing code out of
config.[c|h] and into config-parse.[c|h]. Do this without making changes
to interfaces or function bodies, but tweak visibility and includes
where appropriate, namely:

- git_config_from_stdin() is now non-static so that it can be seen by
  config.c.

- "struct config_source" is now defined in the .h file so that it can be
  seen by config.c. And as a result, config-lib.h needs to "#include
  strbuf.h".

The resulting library is usable, though it is unergonomic to do so,
e.g. the caller needs to "#include git-compat-util.h" and other
dependencies, and we don't have an easy way of linking in the required
objects besides using all of libgit.a. This isn't the end state we want
for our libraries, but at least we have _some_ library whose usability
we can improve in future series.

Signed-off-by: Glen Choo <[email protected]>
  • Loading branch information
chooglen committed Jul 17, 2023
1 parent 9924481 commit 6f445de
Show file tree
Hide file tree
Showing 6 changed files with 796 additions and 778 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,7 @@ LIB_OBJS += compat/obstack.o
LIB_OBJS += compat/terminal.o
LIB_OBJS += compat/zlib-uncompress2.o
LIB_OBJS += config.o
LIB_OBJS += config-parse.o
LIB_OBJS += connect.o
LIB_OBJS += connected.o
LIB_OBJS += convert.o
Expand Down
Loading

0 comments on commit 6f445de

Please sign in to comment.