From: Felipe Contreras <felipe.contreras@gmail.com>
To: git@vger.kernel.org
Cc: Felipe Contreras <felipe.contreras@gmail.com>,
Emily Shaffer <nasamuffin@google.com>
Subject: [PATCH] lib: add new libgit-builtin
Date: Fri, 12 May 2023 16:52:00 -0600 [thread overview]
Message-ID: <20230512225200.2214534-1-felipe.contreras@gmail.com> (raw)
Since its creation in 0a02ce72d9 (Clean up the Makefile a bit.,
2005-04-18), libgit.a has been used as dumping ground for everything all
git commands use.
When the code was split between `*.c` and `builtin/*.c` it was never
clarified what belongs in what category.
The code in `*.c` can be shared by all builtins, but so can the code in
`builtin/*.c`.
There's no practical difference.
In order to attempt to start decoupling libgit.a from the `git` binary,
let's create a new libgit-builtin.a library meant only for the code in
`builtin/*.c`.
Ideally eventually libgit.a would not contain code that is specific to
`git`, only code that is generic and could be used by projects outside
git.git.
This is an essential step that has to be done if there's any hope of
ever having a public libgit.so library.
The choice of notes-utils.c is mostly arbitrary, but its functions had
been discussed before as a roadblock for a proper libgit. In particular
something like `init_copy_notes_for_rewrite("am")` does not seem like
something anyone outside `git` would want to call.
Cc: Emily Shaffer <nasamuffin@google.com>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
After re-reading a previous thread about the lbification of git [1], I
realized `init_copy_notes_for_rewrite()` and others which now belong in
notes-utils.c are good candidates to start splitting away from what
eventually should be a public libgit.so library.
[1] https://lore.kernel.org/git/1370712574-27688-1-git-send-email-felipe.contreras@gmail.com/
Makefile | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index e440728c24..84cbb35828 100644
--- a/Makefile
+++ b/Makefile
@@ -668,6 +668,7 @@ FUZZ_OBJS =
FUZZ_PROGRAMS =
GIT_OBJS =
LIB_OBJS =
+BUILTIN_LIB_OBJS =
SCALAR_OBJS =
OBJECTS =
OTHER_PROGRAMS =
@@ -916,6 +917,7 @@ export PYTHON_PATH
TEST_SHELL_PATH = $(SHELL_PATH)
LIB_FILE = libgit.a
+BUILTIN_LIB_FILE = libgit-builtin.a
XDIFF_LIB = xdiff/lib.a
REFTABLE_LIB = reftable/libreftable.a
REFTABLE_TEST_LIB = reftable/libreftable_test.a
@@ -1071,7 +1073,6 @@ LIB_OBJS += negotiator/noop.o
LIB_OBJS += negotiator/skipping.o
LIB_OBJS += notes-cache.o
LIB_OBJS += notes-merge.o
-LIB_OBJS += notes-utils.o
LIB_OBJS += notes.o
LIB_OBJS += object-file.o
LIB_OBJS += object-name.o
@@ -1194,6 +1195,8 @@ LIB_OBJS += ws.o
LIB_OBJS += wt-status.o
LIB_OBJS += xdiff-interface.o
+BUILTIN_LIB_OBJS += notes-utils.o
+
BUILTIN_OBJS += builtin/add.o
BUILTIN_OBJS += builtin/am.o
BUILTIN_OBJS += builtin/annotate.o
@@ -1332,7 +1335,7 @@ THIRD_PARTY_SOURCES += sha1collisiondetection/%
THIRD_PARTY_SOURCES += sha1dc/%
# xdiff and reftable libs may in turn depend on what is in libgit.a
-GITLIBS = common-main.o $(LIB_FILE) $(XDIFF_LIB) $(REFTABLE_LIB) $(LIB_FILE)
+GITLIBS = common-main.o $(LIB_FILE) $(BUILTIN_LIB_FILE) $(XDIFF_LIB) $(REFTABLE_LIB) $(LIB_FILE)
EXTLIBS =
GIT_USER_AGENT = git/$(GIT_VERSION)
@@ -2655,6 +2658,7 @@ TEST_OBJS := $(patsubst %$X,%.o,$(TEST_PROGRAMS)) $(patsubst %,t/helper/%,$(TEST
test-objs: $(TEST_OBJS)
GIT_OBJS += $(LIB_OBJS)
+GIT_OBJS += $(BUILTIN_LIB_OBJS)
GIT_OBJS += $(BUILTIN_OBJS)
GIT_OBJS += common-main.o
GIT_OBJS += git.o
@@ -2809,6 +2813,9 @@ scalar$X: scalar.o GIT-LDFLAGS $(GITLIBS)
$(LIB_FILE): $(LIB_OBJS)
$(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^
+$(BUILTIN_LIB_FILE): $(BUILTIN_LIB_OBJS)
+ $(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^
+
$(XDIFF_LIB): $(XDIFF_OBJS)
$(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^
@@ -3651,7 +3658,7 @@ clean: profile-clean coverage-clean cocciclean
$(RM) po/git.pot po/git-core.pot
$(RM) git.res
$(RM) $(OBJECTS)
- $(RM) $(LIB_FILE) $(XDIFF_LIB) $(REFTABLE_LIB) $(REFTABLE_TEST_LIB)
+ $(RM) $(LIB_FILE) $(BUILTIN_LIB_FILE) $(XDIFF_LIB) $(REFTABLE_LIB) $(REFTABLE_TEST_LIB)
$(RM) $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) $(OTHER_PROGRAMS)
$(RM) $(TEST_PROGRAMS)
$(RM) $(FUZZ_PROGRAMS)
--
2.40.0+fc1
reply other threads:[~2023-05-12 22:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230512225200.2214534-1-felipe.contreras@gmail.com \
--to=felipe.contreras@gmail.com \
--cc=git@vger.kernel.org \
--cc=nasamuffin@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).