Skip to content

Commit 0c47e4c

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 dcfe38d commit 0c47e4c

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
@@ -1724,11 +1724,17 @@ version.sp version.s version.o: EXTRA_CPPFLAGS = \
17241724
'-DGIT_VERSION="$(GIT_VERSION)"' \
17251725
'-DGIT_USER_AGENT=$(GIT_USER_AGENT_CQ_SQ)'
17261726

1727+
ifeq (,$(BUILT_IN_WRAPPER))
17271728
$(BUILT_INS): git$X
17281729
$(QUIET_BUILT_IN)$(RM) $@ && \
17291730
ln $< $@ 2>/dev/null || \
17301731
ln -s $< $@ 2>/dev/null || \
17311732
cp $< $@
1733+
else
1734+
$(BUILT_INS): $(BUILT_IN_WRAPPER)
1735+
$(QUIET_BUILT_IN)$(RM) $@ && \
1736+
cp $< $@
1737+
endif
17321738

17331739
common-cmds.h: generate-cmdlist.sh command-list.txt
17341740

@@ -2297,6 +2303,24 @@ profile-install: profile
22972303
profile-fast-install: profile-fast
22982304
$(MAKE) install
22992305

2306+
ifeq (,$(BUILT_IN_WRAPPER))
2307+
LN_OR_CP_BUILT_IN_BINDIR = \
2308+
test -z "$(NO_INSTALL_HARDLINKS)" && \
2309+
ln "$$bindir/git$X" "$$bindir/$$p" 2>/dev/null || \
2310+
ln -s "git$X" "$$bindir/$$p" 2>/dev/null || \
2311+
cp "$$bindir/git$X" "$$bindir/$$p" || exit;
2312+
LN_OR_CP_BUILT_IN_EXECDIR = \
2313+
test -z "$(NO_INSTALL_HARDLINKS)" && \
2314+
ln "$$execdir/git$X" "$$execdir/$$p" 2>/dev/null || \
2315+
ln -s "git$X" "$$execdir/$$p" 2>/dev/null || \
2316+
cp "$$execdir/git$X" "$$execdir/$$p" || exit;
2317+
else
2318+
LN_OR_CP_BUILT_IN_BINDIR = \
2319+
cp "$(BUILT_IN_WRAPPER)" "$$bindir/$$p" || exit;
2320+
LN_OR_CP_BUILT_IN_EXECDIR = \
2321+
cp "$(BUILT_IN_WRAPPER)" "$$execdir/$$p" || exit;
2322+
endif
2323+
23002324
install: all
23012325
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
23022326
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
@@ -2335,17 +2359,11 @@ endif
23352359
} && \
23362360
for p in $(filter $(install_bindir_programs),$(BUILT_INS)); do \
23372361
$(RM) "$$bindir/$$p" && \
2338-
test -z "$(NO_INSTALL_HARDLINKS)" && \
2339-
ln "$$bindir/git$X" "$$bindir/$$p" 2>/dev/null || \
2340-
ln -s "git$X" "$$bindir/$$p" 2>/dev/null || \
2341-
cp "$$bindir/git$X" "$$bindir/$$p" || exit; \
2362+
$(LN_OR_CP_BUILT_IN_BINDIR) \
23422363
done && \
23432364
for p in $(BUILT_INS); do \
23442365
$(RM) "$$execdir/$$p" && \
2345-
test -z "$(NO_INSTALL_HARDLINKS)" && \
2346-
ln "$$execdir/git$X" "$$execdir/$$p" 2>/dev/null || \
2347-
ln -s "git$X" "$$execdir/$$p" 2>/dev/null || \
2348-
cp "$$execdir/git$X" "$$execdir/$$p" || exit; \
2366+
$(LN_OR_CP_BUILT_IN_EXECDIR) \
23492367
done && \
23502368
remote_curl_aliases="$(REMOTE_CURL_ALIASES)" && \
23512369
for p in $$remote_curl_aliases; do \

config.mak.uname

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,7 @@ else
573573
NO_CURL = YesPlease
574574
endif
575575
OTHER_PROGRAMS += git-wrapper$(X)
576+
BUILT_IN_WRAPPER = git-wrapper$(X)
576577

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

0 commit comments

Comments
 (0)