Skip to content

Commit 1cda8e7

Browse files
committed
mingw: Use the Git wrapper for builtins
This reduces the disk footprint of a full Git for Windows setup dramatically because on Windows, one cannot assume that hard links are supported. The net savings are calculated easily: the 32-bit `git.exe` file weighs in with 7662 kB while the `git-wrapper.exe` file (modified to serve as a drop-in replacement for builtins) weighs a scant 21 kB. At this point, there are 109 builtins which results in a total of 813 MB disk space being freed up by this commit. Yes, that is really more than half a gigabyte. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 701ca95 commit 1cda8e7

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

Makefile

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,11 +1730,17 @@ version.sp version.s version.o: EXTRA_CPPFLAGS = \
17301730
'-DGIT_VERSION="$(GIT_VERSION)"' \
17311731
'-DGIT_USER_AGENT=$(GIT_USER_AGENT_CQ_SQ)'
17321732

1733+
ifeq (,$(BUILT_IN_WRAPPER))
17331734
$(BUILT_INS): git$X
17341735
$(QUIET_BUILT_IN)$(RM) $@ && \
17351736
ln $< $@ 2>/dev/null || \
17361737
ln -s $< $@ 2>/dev/null || \
17371738
cp $< $@
1739+
else
1740+
$(BUILT_INS): $(BUILT_IN_WRAPPER)
1741+
$(QUIET_BUILT_IN)$(RM) $@ && \
1742+
cp $< $@
1743+
endif
17381744

17391745
common-cmds.h: generate-cmdlist.sh command-list.txt
17401746

@@ -2303,6 +2309,24 @@ profile-install: profile
23032309
profile-fast-install: profile-fast
23042310
$(MAKE) install
23052311

2312+
ifeq (,$(BUILT_IN_WRAPPER))
2313+
LN_OR_CP_BUILT_IN_BINDIR = \
2314+
test -z "$(NO_INSTALL_HARDLINKS)" && \
2315+
ln "$$bindir/git$X" "$$bindir/$$p" 2>/dev/null || \
2316+
ln -s "git$X" "$$bindir/$$p" 2>/dev/null || \
2317+
cp "$$bindir/git$X" "$$bindir/$$p" || exit;
2318+
LN_OR_CP_BUILT_IN_EXECDIR = \
2319+
test -z "$(NO_INSTALL_HARDLINKS)" && \
2320+
ln "$$execdir/git$X" "$$execdir/$$p" 2>/dev/null || \
2321+
ln -s "git$X" "$$execdir/$$p" 2>/dev/null || \
2322+
cp "$$execdir/git$X" "$$execdir/$$p" || exit;
2323+
else
2324+
LN_OR_CP_BUILT_IN_BINDIR = \
2325+
cp "$(BUILT_IN_WRAPPER)" "$$bindir/$$p" || exit;
2326+
LN_OR_CP_BUILT_IN_EXECDIR = \
2327+
cp "$(BUILT_IN_WRAPPER)" "$$execdir/$$p" || exit;
2328+
endif
2329+
23062330
install: all
23072331
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
23082332
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
@@ -2341,17 +2365,11 @@ endif
23412365
} && \
23422366
for p in $(filter $(install_bindir_programs),$(BUILT_INS)); do \
23432367
$(RM) "$$bindir/$$p" && \
2344-
test -z "$(NO_INSTALL_HARDLINKS)" && \
2345-
ln "$$bindir/git$X" "$$bindir/$$p" 2>/dev/null || \
2346-
ln -s "git$X" "$$bindir/$$p" 2>/dev/null || \
2347-
cp "$$bindir/git$X" "$$bindir/$$p" || exit; \
2368+
$(LN_OR_CP_BUILT_IN_BINDIR) \
23482369
done && \
23492370
for p in $(BUILT_INS); do \
23502371
$(RM) "$$execdir/$$p" && \
2351-
test -z "$(NO_INSTALL_HARDLINKS)" && \
2352-
ln "$$execdir/git$X" "$$execdir/$$p" 2>/dev/null || \
2353-
ln -s "git$X" "$$execdir/$$p" 2>/dev/null || \
2354-
cp "$$execdir/git$X" "$$execdir/$$p" || exit; \
2372+
$(LN_OR_CP_BUILT_IN_EXECDIR) \
23552373
done && \
23562374
remote_curl_aliases="$(REMOTE_CURL_ALIASES)" && \
23572375
for p in $$remote_curl_aliases; do \

config.mak.uname

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,7 @@ else
571571
NO_CURL = YesPlease
572572
endif
573573
OTHER_PROGRAMS += git-wrapper$(X)
574+
BUILT_IN_WRAPPER = git-wrapper$(X)
574575

575576
git-wrapper$(X): compat/win32/git-wrapper.o git.res
576577
$(QUIET_LINK)$(CC) $(ALL_LDFLAGS) $(COMPAT_CFLAGS) \

0 commit comments

Comments
 (0)