Skip to content

Commit 355d5b7

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 d6b5fcb commit 355d5b7

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
@@ -1714,11 +1714,17 @@ version.sp version.s version.o: EXTRA_CPPFLAGS = \
17141714
'-DGIT_VERSION="$(GIT_VERSION)"' \
17151715
'-DGIT_USER_AGENT=$(GIT_USER_AGENT_CQ_SQ)'
17161716

1717+
ifeq (,$(BUILT_IN_WRAPPER))
17171718
$(BUILT_INS): git$X
17181719
$(QUIET_BUILT_IN)$(RM) $@ && \
17191720
ln $< $@ 2>/dev/null || \
17201721
ln -s $< $@ 2>/dev/null || \
17211722
cp $< $@
1723+
else
1724+
$(BUILT_INS): $(BUILT_IN_WRAPPER)
1725+
$(QUIET_BUILT_IN)$(RM) $@ && \
1726+
cp $< $@
1727+
endif
17221728

17231729
common-cmds.h: generate-cmdlist.sh command-list.txt
17241730

@@ -2283,6 +2289,24 @@ profile-install: profile
22832289
profile-fast-install: profile-fast
22842290
$(MAKE) install
22852291

2292+
ifeq (,$(BUILT_IN_WRAPPER))
2293+
LN_OR_CP_BUILT_IN_BINDIR = \
2294+
test -z "$(NO_INSTALL_HARDLINKS)" && \
2295+
ln "$$bindir/git$X" "$$bindir/$$p" 2>/dev/null || \
2296+
ln -s "git$X" "$$bindir/$$p" 2>/dev/null || \
2297+
cp "$$bindir/git$X" "$$bindir/$$p" || exit;
2298+
LN_OR_CP_BUILT_IN_EXECDIR = \
2299+
test -z "$(NO_INSTALL_HARDLINKS)" && \
2300+
ln "$$execdir/git$X" "$$execdir/$$p" 2>/dev/null || \
2301+
ln -s "git$X" "$$execdir/$$p" 2>/dev/null || \
2302+
cp "$$execdir/git$X" "$$execdir/$$p" || exit;
2303+
else
2304+
LN_OR_CP_BUILT_IN_BINDIR = \
2305+
cp "$(BUILT_IN_WRAPPER)" "$$bindir/$$p" || exit;
2306+
LN_OR_CP_BUILT_IN_EXECDIR = \
2307+
cp "$(BUILT_IN_WRAPPER)" "$$execdir/$$p" || exit;
2308+
endif
2309+
22862310
install: all
22872311
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
22882312
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
@@ -2321,17 +2345,11 @@ endif
23212345
} && \
23222346
for p in $(filter $(install_bindir_programs),$(BUILT_INS)); do \
23232347
$(RM) "$$bindir/$$p" && \
2324-
test -z "$(NO_INSTALL_HARDLINKS)" && \
2325-
ln "$$bindir/git$X" "$$bindir/$$p" 2>/dev/null || \
2326-
ln -s "git$X" "$$bindir/$$p" 2>/dev/null || \
2327-
cp "$$bindir/git$X" "$$bindir/$$p" || exit; \
2348+
$(LN_OR_CP_BUILT_IN_BINDIR) \
23282349
done && \
23292350
for p in $(BUILT_INS); do \
23302351
$(RM) "$$execdir/$$p" && \
2331-
test -z "$(NO_INSTALL_HARDLINKS)" && \
2332-
ln "$$execdir/git$X" "$$execdir/$$p" 2>/dev/null || \
2333-
ln -s "git$X" "$$execdir/$$p" 2>/dev/null || \
2334-
cp "$$execdir/git$X" "$$execdir/$$p" || exit; \
2352+
$(LN_OR_CP_BUILT_IN_EXECDIR) \
23352353
done && \
23362354
remote_curl_aliases="$(REMOTE_CURL_ALIASES)" && \
23372355
for p in $$remote_curl_aliases; do \

config.mak.uname

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

576577
git-wrapper$(X): compat/win32/git-wrapper.o git.res
577578
$(QUIET_LINK)$(CC) -Wall -s -o $@ $^ -lshell32 -lshlwapi

0 commit comments

Comments
 (0)