Skip to content

Commit f215118

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 3d1efd5 commit f215118

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
@@ -1681,11 +1681,17 @@ version.sp version.s version.o: EXTRA_CPPFLAGS = \
16811681
'-DGIT_VERSION="$(GIT_VERSION)"' \
16821682
'-DGIT_USER_AGENT=$(GIT_USER_AGENT_CQ_SQ)'
16831683

1684+
ifeq (,$(BUILT_IN_WRAPPER))
16841685
$(BUILT_INS): git$X
16851686
$(QUIET_BUILT_IN)$(RM) $@ && \
16861687
ln $< $@ 2>/dev/null || \
16871688
ln -s $< $@ 2>/dev/null || \
16881689
cp $< $@
1690+
else
1691+
$(BUILT_INS): $(BUILT_IN_WRAPPER)
1692+
$(QUIET_BUILT_IN)$(RM) $@ && \
1693+
cp $< $@
1694+
endif
16891695

16901696
common-cmds.h: ./generate-cmdlist.sh command-list.txt
16911697

@@ -2248,6 +2254,24 @@ profile-install: profile
22482254
profile-fast-install: profile-fast
22492255
$(MAKE) install
22502256

2257+
ifeq (,$(BUILT_IN_WRAPPER))
2258+
LN_OR_CP_BUILT_IN_BINDIR = \
2259+
test -z "$(NO_INSTALL_HARDLINKS)" && \
2260+
ln "$$bindir/git$X" "$$bindir/$$p" 2>/dev/null || \
2261+
ln -s "git$X" "$$bindir/$$p" 2>/dev/null || \
2262+
cp "$$bindir/git$X" "$$bindir/$$p" || exit;
2263+
LN_OR_CP_BUILT_IN_EXECDIR = \
2264+
test -z "$(NO_INSTALL_HARDLINKS)" && \
2265+
ln "$$exectir/git$X" "$$exectir/$$p" 2>/dev/null || \
2266+
ln -s "git$X" "$$exectir/$$p" 2>/dev/null || \
2267+
cp "$$exectir/git$X" "$$exectir/$$p" || exit;
2268+
else
2269+
LN_OR_CP_BUILT_IN_BINDIR = \
2270+
cp "$(BUILT_IN_WRAPPER)" "$$bindir/$$p" || exit;
2271+
LN_OR_CP_BUILT_IN_EXECDIR = \
2272+
cp "$(BUILT_IN_WRAPPER)" "$$execdir/$$p" || exit;
2273+
endif
2274+
22512275
install: all
22522276
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
22532277
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
@@ -2286,17 +2310,11 @@ endif
22862310
} && \
22872311
for p in $(filter $(install_bindir_programs),$(BUILT_INS)); do \
22882312
$(RM) "$$bindir/$$p" && \
2289-
test -z "$(NO_INSTALL_HARDLINKS)" && \
2290-
ln "$$bindir/git$X" "$$bindir/$$p" 2>/dev/null || \
2291-
ln -s "git$X" "$$bindir/$$p" 2>/dev/null || \
2292-
cp "$$bindir/git$X" "$$bindir/$$p" || exit; \
2313+
$(LN_OR_CP_BUILT_IN_BINDIR) \
22932314
done && \
22942315
for p in $(BUILT_INS); do \
22952316
$(RM) "$$execdir/$$p" && \
2296-
test -z "$(NO_INSTALL_HARDLINKS)" && \
2297-
ln "$$execdir/git$X" "$$execdir/$$p" 2>/dev/null || \
2298-
ln -s "git$X" "$$execdir/$$p" 2>/dev/null || \
2299-
cp "$$execdir/git$X" "$$execdir/$$p" || exit; \
2317+
$(LN_OR_CP_BUILT_IN_EXECDIR) \
23002318
done && \
23012319
remote_curl_aliases="$(REMOTE_CURL_ALIASES)" && \
23022320
for p in $$remote_curl_aliases; do \

config.mak.uname

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

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

0 commit comments

Comments
 (0)