Skip to content

Commit df30321

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 <johannes.schindelin@gmx.de>
1 parent fba4cbb commit df30321

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
@@ -1672,11 +1672,17 @@ version.sp version.s version.o: EXTRA_CPPFLAGS = \
16721672
'-DGIT_VERSION="$(GIT_VERSION)"' \
16731673
'-DGIT_USER_AGENT=$(GIT_USER_AGENT_CQ_SQ)'
16741674

1675+
ifeq (,$(BUILT_IN_WRAPPER))
16751676
$(BUILT_INS): git$X
16761677
$(QUIET_BUILT_IN)$(RM) $@ && \
16771678
ln $< $@ 2>/dev/null || \
16781679
ln -s $< $@ 2>/dev/null || \
16791680
cp $< $@
1681+
else
1682+
$(BUILT_INS): $(BUILT_IN_WRAPPER)
1683+
$(QUIET_BUILT_IN)$(RM) $@ && \
1684+
cp $< $@
1685+
endif
16801686

16811687
common-cmds.h: ./generate-cmdlist.sh command-list.txt
16821688

@@ -2239,6 +2245,24 @@ profile-install: profile
22392245
profile-fast-install: profile-fast
22402246
$(MAKE) install
22412247

2248+
ifeq (,$(BUILT_IN_WRAPPER))
2249+
LN_OR_CP_BUILT_IN_BINDIR = \
2250+
test -z "$(NO_INSTALL_HARDLINKS)" && \
2251+
ln "$$bindir/git$X" "$$bindir/$$p" 2>/dev/null || \
2252+
ln -s "git$X" "$$bindir/$$p" 2>/dev/null || \
2253+
cp "$$bindir/git$X" "$$bindir/$$p" || exit;
2254+
LN_OR_CP_BUILT_IN_EXECDIR = \
2255+
test -z "$(NO_INSTALL_HARDLINKS)" && \
2256+
ln "$$exectir/git$X" "$$exectir/$$p" 2>/dev/null || \
2257+
ln -s "git$X" "$$exectir/$$p" 2>/dev/null || \
2258+
cp "$$exectir/git$X" "$$exectir/$$p" || exit;
2259+
else
2260+
LN_OR_CP_BUILT_IN_BINDIR = \
2261+
cp "$(BUILT_IN_WRAPPER)" "$$bindir/$$p" || exit;
2262+
LN_OR_CP_BUILT_IN_EXECDIR = \
2263+
cp "$(BUILT_IN_WRAPPER)" "$$execdir/$$p" || exit;
2264+
endif
2265+
22422266
install: all
22432267
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
22442268
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
@@ -2277,17 +2301,11 @@ endif
22772301
} && \
22782302
for p in $(filter $(install_bindir_programs),$(BUILT_INS)); do \
22792303
$(RM) "$$bindir/$$p" && \
2280-
test -z "$(NO_INSTALL_HARDLINKS)" && \
2281-
ln "$$bindir/git$X" "$$bindir/$$p" 2>/dev/null || \
2282-
ln -s "git$X" "$$bindir/$$p" 2>/dev/null || \
2283-
cp "$$bindir/git$X" "$$bindir/$$p" || exit; \
2304+
$(LN_OR_CP_BUILT_IN_BINDIR) \
22842305
done && \
22852306
for p in $(BUILT_INS); do \
22862307
$(RM) "$$execdir/$$p" && \
2287-
test -z "$(NO_INSTALL_HARDLINKS)" && \
2288-
ln "$$execdir/git$X" "$$execdir/$$p" 2>/dev/null || \
2289-
ln -s "git$X" "$$execdir/$$p" 2>/dev/null || \
2290-
cp "$$execdir/git$X" "$$execdir/$$p" || exit; \
2308+
$(LN_OR_CP_BUILT_IN_EXECDIR) \
22912309
done && \
22922310
remote_curl_aliases="$(REMOTE_CURL_ALIASES)" && \
22932311
for p in $$remote_curl_aliases; do \

config.mak.uname

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))
525525
X = .exe
526526
SPARSE_FLAGS = -Wno-one-bit-signed-bitfield
527527
OTHER_PROGRAMS += git-wrapper$(X)
528+
BUILT_IN_WRAPPER = git-wrapper$(X)
528529
ifneq (,$(wildcard ../THIS_IS_MSYSGIT))
529530
htmldir = share/doc/git/$(firstword $(subst -, ,$(GIT_VERSION)))/html
530531
prefix =

0 commit comments

Comments
 (0)