Skip to content

Commit f668b83

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 1f7ff4b commit f668b83

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
@@ -1694,11 +1694,17 @@ version.sp version.s version.o: EXTRA_CPPFLAGS = \
16941694
'-DGIT_VERSION="$(GIT_VERSION)"' \
16951695
'-DGIT_USER_AGENT=$(GIT_USER_AGENT_CQ_SQ)'
16961696

1697+
ifeq (,$(BUILT_IN_WRAPPER))
16971698
$(BUILT_INS): git$X
16981699
$(QUIET_BUILT_IN)$(RM) $@ && \
16991700
ln $< $@ 2>/dev/null || \
17001701
ln -s $< $@ 2>/dev/null || \
17011702
cp $< $@
1703+
else
1704+
$(BUILT_INS): $(BUILT_IN_WRAPPER)
1705+
$(QUIET_BUILT_IN)$(RM) $@ && \
1706+
cp $< $@
1707+
endif
17021708

17031709
common-cmds.h: generate-cmdlist.sh command-list.txt
17041710

@@ -2263,6 +2269,24 @@ profile-install: profile
22632269
profile-fast-install: profile-fast
22642270
$(MAKE) install
22652271

2272+
ifeq (,$(BUILT_IN_WRAPPER))
2273+
LN_OR_CP_BUILT_IN_BINDIR = \
2274+
test -z "$(NO_INSTALL_HARDLINKS)" && \
2275+
ln "$$bindir/git$X" "$$bindir/$$p" 2>/dev/null || \
2276+
ln -s "git$X" "$$bindir/$$p" 2>/dev/null || \
2277+
cp "$$bindir/git$X" "$$bindir/$$p" || exit;
2278+
LN_OR_CP_BUILT_IN_EXECDIR = \
2279+
test -z "$(NO_INSTALL_HARDLINKS)" && \
2280+
ln "$$execdir/git$X" "$$execdir/$$p" 2>/dev/null || \
2281+
ln -s "git$X" "$$execdir/$$p" 2>/dev/null || \
2282+
cp "$$execdir/git$X" "$$execdir/$$p" || exit;
2283+
else
2284+
LN_OR_CP_BUILT_IN_BINDIR = \
2285+
cp "$(BUILT_IN_WRAPPER)" "$$bindir/$$p" || exit;
2286+
LN_OR_CP_BUILT_IN_EXECDIR = \
2287+
cp "$(BUILT_IN_WRAPPER)" "$$execdir/$$p" || exit;
2288+
endif
2289+
22662290
install: all
22672291
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
22682292
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
@@ -2301,17 +2325,11 @@ endif
23012325
} && \
23022326
for p in $(filter $(install_bindir_programs),$(BUILT_INS)); do \
23032327
$(RM) "$$bindir/$$p" && \
2304-
test -z "$(NO_INSTALL_HARDLINKS)" && \
2305-
ln "$$bindir/git$X" "$$bindir/$$p" 2>/dev/null || \
2306-
ln -s "git$X" "$$bindir/$$p" 2>/dev/null || \
2307-
cp "$$bindir/git$X" "$$bindir/$$p" || exit; \
2328+
$(LN_OR_CP_BUILT_IN_BINDIR) \
23082329
done && \
23092330
for p in $(BUILT_INS); do \
23102331
$(RM) "$$execdir/$$p" && \
2311-
test -z "$(NO_INSTALL_HARDLINKS)" && \
2312-
ln "$$execdir/git$X" "$$execdir/$$p" 2>/dev/null || \
2313-
ln -s "git$X" "$$execdir/$$p" 2>/dev/null || \
2314-
cp "$$execdir/git$X" "$$execdir/$$p" || exit; \
2332+
$(LN_OR_CP_BUILT_IN_EXECDIR) \
23152333
done && \
23162334
remote_curl_aliases="$(REMOTE_CURL_ALIASES)" && \
23172335
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) -Wall -s -o $@ $^ -lshell32 -lshlwapi

0 commit comments

Comments
 (0)