Skip to content

Commit ebcdcc3

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 7a57a2a commit ebcdcc3

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

@@ -2289,6 +2295,24 @@ profile-install: profile
22892295
profile-fast-install: profile-fast
22902296
$(MAKE) install
22912297

2298+
ifeq (,$(BUILT_IN_WRAPPER))
2299+
LN_OR_CP_BUILT_IN_BINDIR = \
2300+
test -z "$(NO_INSTALL_HARDLINKS)" && \
2301+
ln "$$bindir/git$X" "$$bindir/$$p" 2>/dev/null || \
2302+
ln -s "git$X" "$$bindir/$$p" 2>/dev/null || \
2303+
cp "$$bindir/git$X" "$$bindir/$$p" || exit;
2304+
LN_OR_CP_BUILT_IN_EXECDIR = \
2305+
test -z "$(NO_INSTALL_HARDLINKS)" && \
2306+
ln "$$execdir/git$X" "$$execdir/$$p" 2>/dev/null || \
2307+
ln -s "git$X" "$$execdir/$$p" 2>/dev/null || \
2308+
cp "$$execdir/git$X" "$$execdir/$$p" || exit;
2309+
else
2310+
LN_OR_CP_BUILT_IN_BINDIR = \
2311+
cp "$(BUILT_IN_WRAPPER)" "$$bindir/$$p" || exit;
2312+
LN_OR_CP_BUILT_IN_EXECDIR = \
2313+
cp "$(BUILT_IN_WRAPPER)" "$$execdir/$$p" || exit;
2314+
endif
2315+
22922316
install: all
22932317
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
22942318
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
@@ -2327,17 +2351,11 @@ endif
23272351
} && \
23282352
for p in $(filter $(install_bindir_programs),$(BUILT_INS)); do \
23292353
$(RM) "$$bindir/$$p" && \
2330-
test -z "$(NO_INSTALL_HARDLINKS)" && \
2331-
ln "$$bindir/git$X" "$$bindir/$$p" 2>/dev/null || \
2332-
ln -s "git$X" "$$bindir/$$p" 2>/dev/null || \
2333-
cp "$$bindir/git$X" "$$bindir/$$p" || exit; \
2354+
$(LN_OR_CP_BUILT_IN_BINDIR) \
23342355
done && \
23352356
for p in $(BUILT_INS); do \
23362357
$(RM) "$$execdir/$$p" && \
2337-
test -z "$(NO_INSTALL_HARDLINKS)" && \
2338-
ln "$$execdir/git$X" "$$execdir/$$p" 2>/dev/null || \
2339-
ln -s "git$X" "$$execdir/$$p" 2>/dev/null || \
2340-
cp "$$execdir/git$X" "$$execdir/$$p" || exit; \
2358+
$(LN_OR_CP_BUILT_IN_EXECDIR) \
23412359
done && \
23422360
remote_curl_aliases="$(REMOTE_CURL_ALIASES)" && \
23432361
for p in $$remote_curl_aliases; do \

config.mak.uname

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

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

0 commit comments

Comments
 (0)