Skip to content

Commit 5727569

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 7bfa170 commit 5727569

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
@@ -1658,11 +1658,17 @@ version.sp version.s version.o: EXTRA_CPPFLAGS = \
16581658
'-DGIT_VERSION="$(GIT_VERSION)"' \
16591659
'-DGIT_USER_AGENT=$(GIT_USER_AGENT_CQ_SQ)'
16601660

1661+
ifeq (,$(BUILT_IN_WRAPPER))
16611662
$(BUILT_INS): git$X
16621663
$(QUIET_BUILT_IN)$(RM) $@ && \
16631664
ln $< $@ 2>/dev/null || \
16641665
ln -s $< $@ 2>/dev/null || \
16651666
cp $< $@
1667+
else
1668+
$(BUILT_INS): $(BUILT_IN_WRAPPER)
1669+
$(QUIET_BUILT_IN)$(RM) $@ && \
1670+
cp $< $@
1671+
endif
16661672

16671673
common-cmds.h: ./generate-cmdlist.sh command-list.txt
16681674

@@ -2225,6 +2231,24 @@ profile-install: profile
22252231
profile-fast-install: profile-fast
22262232
$(MAKE) install
22272233

2234+
ifeq (,$(BUILT_IN_WRAPPER))
2235+
LN_OR_CP_BUILT_IN_BINDIR = \
2236+
test -z "$(NO_INSTALL_HARDLINKS)" && \
2237+
ln "$$bindir/git$X" "$$bindir/$$p" 2>/dev/null || \
2238+
ln -s "git$X" "$$bindir/$$p" 2>/dev/null || \
2239+
cp "$$bindir/git$X" "$$bindir/$$p" || exit;
2240+
LN_OR_CP_BUILT_IN_EXECDIR = \
2241+
test -z "$(NO_INSTALL_HARDLINKS)" && \
2242+
ln "$$exectir/git$X" "$$exectir/$$p" 2>/dev/null || \
2243+
ln -s "git$X" "$$exectir/$$p" 2>/dev/null || \
2244+
cp "$$exectir/git$X" "$$exectir/$$p" || exit;
2245+
else
2246+
LN_OR_CP_BUILT_IN_BINDIR = \
2247+
cp "$(BUILT_IN_WRAPPER)" "$$bindir/$$p" || exit;
2248+
LN_OR_CP_BUILT_IN_EXECDIR = \
2249+
cp "$(BUILT_IN_WRAPPER)" "$$execdir/$$p" || exit;
2250+
endif
2251+
22282252
install: all
22292253
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
22302254
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
@@ -2263,17 +2287,11 @@ endif
22632287
} && \
22642288
for p in $(filter $(install_bindir_programs),$(BUILT_INS)); do \
22652289
$(RM) "$$bindir/$$p" && \
2266-
test -z "$(NO_INSTALL_HARDLINKS)" && \
2267-
ln "$$bindir/git$X" "$$bindir/$$p" 2>/dev/null || \
2268-
ln -s "git$X" "$$bindir/$$p" 2>/dev/null || \
2269-
cp "$$bindir/git$X" "$$bindir/$$p" || exit; \
2290+
$(LN_OR_CP_BUILT_IN_BINDIR) \
22702291
done && \
22712292
for p in $(BUILT_INS); do \
22722293
$(RM) "$$execdir/$$p" && \
2273-
test -z "$(NO_INSTALL_HARDLINKS)" && \
2274-
ln "$$execdir/git$X" "$$execdir/$$p" 2>/dev/null || \
2275-
ln -s "git$X" "$$execdir/$$p" 2>/dev/null || \
2276-
cp "$$execdir/git$X" "$$execdir/$$p" || exit; \
2294+
$(LN_OR_CP_BUILT_IN_EXECDIR) \
22772295
done && \
22782296
remote_curl_aliases="$(REMOTE_CURL_ALIASES)" && \
22792297
for p in $$remote_curl_aliases; do \

config.mak.uname

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,7 @@ else
562562
NO_CURL = YesPlease
563563
endif
564564
OTHER_PROGRAMS += git-wrapper$(X)
565+
BUILT_IN_WRAPPER = git-wrapper$(X)
565566

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

0 commit comments

Comments
 (0)