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 not change 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".

In theory, this makes it possible for in-tree files to decide whether
they only need all of the config functionality or only config parsing
(e.g. bundle-uri.c only needs config parsing to parse bundle lists), and
bring in the smallest bit of functionality needed. But for now, there
are no in-tree files that can swap "#include config.h" for "#include
config-parse.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. 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 <chooglen@google.com>
  • Loading branch information
chooglen committed Jul 20, 2023
1 parent 9924481 commit 9cb1dca
Show file tree
Hide file tree
Showing 5 changed files with 795 additions and 777 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 9cb1dca

Please sign in to comment.