Skip to content

Commit 179227d

Browse files
dschogitster
authored andcommitted
Optionally skip linking/copying the built-ins
For a long time already, the non-dashed form of the built-ins is the recommended way to write scripts, i.e. it is better to call `git merge [...]` than to call `git-merge [...]`. While Git still supports the dashed form (by hard-linking the `git` executable to the dashed name in `libexec/git-core/`), in practice, it is probably almost irrelevant. However, we *do* care about keeping people's scripts working (even if they were written before the non-dashed form started to be recommended). Keeping this backwards-compatibility is not necessarily cheap, though: even so much as amending the tip commit in a git.git checkout will require re-linking all of those dashed commands. On this developer's laptop, this makes a noticeable difference: $ touch version.c && time make CC version.o AR libgit.a LINK git-bugreport.exe [... 11 similar lines ...] LN/CP git-remote-https.exe LN/CP git-remote-ftp.exe LN/CP git-remote-ftps.exe LINK git.exe BUILTIN git-add.exe [... 123 similar lines ...] BUILTIN all SUBDIR git-gui SUBDIR gitk-git SUBDIR templates LINK t/helper/test-fake-ssh.exe LINK t/helper/test-line-buffer.exe LINK t/helper/test-svn-fe.exe LINK t/helper/test-tool.exe real 0m36.633s user 0m3.794s sys 0m14.141s $ touch version.c && time make SKIP_DASHED_BUILT_INS=1 CC version.o AR libgit.a LINK git-bugreport.exe [... 11 similar lines ...] LN/CP git-remote-https.exe LN/CP git-remote-ftp.exe LN/CP git-remote-ftps.exe LINK git.exe BUILTIN git-receive-pack.exe BUILTIN git-upload-archive.exe BUILTIN git-upload-pack.exe BUILTIN all SUBDIR git-gui SUBDIR gitk-git SUBDIR templates LINK t/helper/test-fake-ssh.exe LINK t/helper/test-line-buffer.exe LINK t/helper/test-svn-fe.exe LINK t/helper/test-tool.exe real 0m23.717s user 0m1.562s sys 0m5.210s Also, `.zip` files do not have any standardized support for hard-links, therefore "zipping up" the executables will result in inflated disk usage. (To keep down the size of the "MinGit" variant of Git for Windows, which is distributed as a `.zip` file, the hard-links are excluded specifically.) In addition to that, some programs that are regularly used to assess disk usage fail to realize that those are hard-links, and heavily overcount disk usage. Most notably, this was the case with Windows Explorer up until the last couple of Windows 10 versions. See e.g. msysgit/msysgit#58. To save on the time needed to hard-link these dashed commands, with the plan to eventually stop shipping with those hard-links on Windows, let's introduce a Makefile knob to skip generating them. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a8b5355 commit 179227d

File tree

1 file changed

+37
-18
lines changed

1 file changed

+37
-18
lines changed

Makefile

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,9 @@ all::
348348
# Define NO_INSTALL_HARDLINKS if you prefer to use either symbolic links or
349349
# copies to install built-in git commands e.g. git-cat-file.
350350
#
351+
# Define SKIP_DASHED_BUILT_INS if you do not need the dashed versions of the
352+
# built-ins to be linked/copied at all.
353+
#
351354
# Define USE_NED_ALLOCATOR if you want to replace the platforms default
352355
# memory allocators with the nedmalloc allocator written by Niall Douglas.
353356
#
@@ -774,6 +777,16 @@ BUILT_INS += git-whatchanged$X
774777
# what 'all' will build and 'install' will install in gitexecdir,
775778
# excluding programs for built-in commands
776779
ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
780+
ALL_COMMANDS_TO_INSTALL = $(ALL_PROGRAMS)
781+
ifeq (,$(SKIP_DASHED_BUILT_INS))
782+
ALL_COMMANDS_TO_INSTALL += $(BUILT_INS)
783+
else
784+
# git-upload-pack, git-receive-pack and git-upload-archive are special: they
785+
# are _expected_ to be present in the `bin/` directory in their dashed form.
786+
ALL_COMMANDS_TO_INSTALL += git-receive-pack$(X)
787+
ALL_COMMANDS_TO_INSTALL += git-upload-archive$(X)
788+
ALL_COMMANDS_TO_INSTALL += git-upload-pack$(X)
789+
endif
777790

778791
# what 'all' will build but not install in gitexecdir
779792
OTHER_PROGRAMS = git$X
@@ -2088,9 +2101,9 @@ profile-fast: profile-clean
20882101
$(MAKE) PROFILE=USE all
20892102

20902103

2091-
all:: $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) $(OTHER_PROGRAMS) GIT-BUILD-OPTIONS
2104+
all:: $(ALL_COMMANDS_TO_INSTALL) $(SCRIPT_LIB) $(OTHER_PROGRAMS) GIT-BUILD-OPTIONS
20922105
ifneq (,$X)
2093-
$(QUIET_BUILT_IN)$(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), test -d '$p' -o '$p' -ef '$p$X' || $(RM) '$p';)
2106+
$(QUIET_BUILT_IN)$(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_COMMANDS_TO_INSTALL) git$X)), test -d '$p' -o '$p' -ef '$p$X' || $(RM) '$p';)
20942107
endif
20952108

20962109
all::
@@ -2950,7 +2963,7 @@ ifndef NO_TCLTK
29502963
$(MAKE) -C git-gui gitexecdir='$(gitexec_instdir_SQ)' install
29512964
endif
29522965
ifneq (,$X)
2953-
$(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), test '$(DESTDIR_SQ)$(gitexec_instdir_SQ)/$p' -ef '$(DESTDIR_SQ)$(gitexec_instdir_SQ)/$p$X' || $(RM) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)/$p';)
2966+
$(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_COMMANDS_TO_INSTALL) git$X)), test '$(DESTDIR_SQ)$(gitexec_instdir_SQ)/$p' -ef '$(DESTDIR_SQ)$(gitexec_instdir_SQ)/$p$X' || $(RM) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)/$p';)
29542967
endif
29552968

29562969
bindir=$$(cd '$(DESTDIR_SQ)$(bindir_SQ)' && pwd) && \
@@ -2968,21 +2981,27 @@ endif
29682981
} && \
29692982
for p in $(filter $(install_bindir_programs),$(BUILT_INS)); do \
29702983
$(RM) "$$bindir/$$p" && \
2971-
test -n "$(INSTALL_SYMLINKS)" && \
2972-
ln -s "git$X" "$$bindir/$$p" || \
2973-
{ test -z "$(NO_INSTALL_HARDLINKS)" && \
2974-
ln "$$bindir/git$X" "$$bindir/$$p" 2>/dev/null || \
2975-
ln -s "git$X" "$$bindir/$$p" 2>/dev/null || \
2976-
cp "$$bindir/git$X" "$$bindir/$$p" || exit; } \
2984+
if test -z "$(SKIP_DASHED_BUILT_INS)"; \
2985+
then \
2986+
test -n "$(INSTALL_SYMLINKS)" && \
2987+
ln -s "git$X" "$$bindir/$$p" || \
2988+
{ test -z "$(NO_INSTALL_HARDLINKS)" && \
2989+
ln "$$bindir/git$X" "$$bindir/$$p" 2>/dev/null || \
2990+
ln -s "git$X" "$$bindir/$$p" 2>/dev/null || \
2991+
cp "$$bindir/git$X" "$$bindir/$$p" || exit; }; \
2992+
fi \
29772993
done && \
29782994
for p in $(BUILT_INS); do \
29792995
$(RM) "$$execdir/$$p" && \
2980-
test -n "$(INSTALL_SYMLINKS)" && \
2981-
ln -s "$$destdir_from_execdir_SQ/$(bindir_relative_SQ)/git$X" "$$execdir/$$p" || \
2982-
{ test -z "$(NO_INSTALL_HARDLINKS)" && \
2983-
ln "$$execdir/git$X" "$$execdir/$$p" 2>/dev/null || \
2984-
ln -s "git$X" "$$execdir/$$p" 2>/dev/null || \
2985-
cp "$$execdir/git$X" "$$execdir/$$p" || exit; } \
2996+
if test -z "$(SKIP_DASHED_BUILT_INS)"; \
2997+
then \
2998+
test -n "$(INSTALL_SYMLINKS)" && \
2999+
ln -s "$$destdir_from_execdir_SQ/$(bindir_relative_SQ)/git$X" "$$execdir/$$p" || \
3000+
{ test -z "$(NO_INSTALL_HARDLINKS)" && \
3001+
ln "$$execdir/git$X" "$$execdir/$$p" 2>/dev/null || \
3002+
ln -s "git$X" "$$execdir/$$p" 2>/dev/null || \
3003+
cp "$$execdir/git$X" "$$execdir/$$p" || exit; }; \
3004+
fi \
29863005
done && \
29873006
remote_curl_aliases="$(REMOTE_CURL_ALIASES)" && \
29883007
for p in $$remote_curl_aliases; do \
@@ -3076,7 +3095,7 @@ ifneq ($(INCLUDE_DLLS_IN_ARTIFACTS),)
30763095
OTHER_PROGRAMS += $(shell echo *.dll t/helper/*.dll)
30773096
endif
30783097

3079-
artifacts-tar:: $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) $(OTHER_PROGRAMS) \
3098+
artifacts-tar:: $(ALL_COMMANDS_TO_INSTALL) $(SCRIPT_LIB) $(OTHER_PROGRAMS) \
30803099
GIT-BUILD-OPTIONS $(TEST_PROGRAMS) $(test_bindir_programs) \
30813100
$(MOFILES)
30823101
$(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1) \
@@ -3171,7 +3190,7 @@ endif
31713190

31723191
### Check documentation
31733192
#
3174-
ALL_COMMANDS = $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS)
3193+
ALL_COMMANDS = $(ALL_COMMANDS_TO_INSTALL) $(SCRIPT_LIB)
31753194
ALL_COMMANDS += git
31763195
ALL_COMMANDS += git-citool
31773196
ALL_COMMANDS += git-gui
@@ -3211,7 +3230,7 @@ check-docs::
32113230
-e 's/\.txt//'; \
32123231
) | while read how cmd; \
32133232
do \
3214-
case " $(patsubst %$X,%,$(ALL_COMMANDS) $(EXCLUDED_PROGRAMS)) " in \
3233+
case " $(patsubst %$X,%,$(ALL_COMMANDS) $(BUILT_INS) $(EXCLUDED_PROGRAMS)) " in \
32153234
*" $$cmd "*) ;; \
32163235
*) echo "removed but $$how: $$cmd" ;; \
32173236
esac; \

0 commit comments

Comments
 (0)