diff --git a/Makefile b/Makefile index 36fa094462..456681b27c 100644 --- a/Makefile +++ b/Makefile @@ -39,6 +39,9 @@ all: # Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link. # Enable it on Windows. By default, symrefs are still used. # +# Define NO_HARDLINKS if you want to disable hard linking in git clone. +# Enable it on Windows. +# # Define NO_SVN_TESTS if you want to skip time-consuming SVN interoperability # tests. These tests take up a significant amount of the total test time # but are not needed unless you plan to talk to SVN repos. @@ -482,6 +485,7 @@ ifneq (,$(findstring MINGW,$(uname_S))) NO_PREAD=YesPlease NO_OPENSSL=YesPlease NO_SYMLINK_HEAD=YesPlease + NO_HARDLINKS=YesPlease NO_IPV6=YesPlease NO_ETC_PASSWD=YesPlease NO_SETENV=YesPlease @@ -724,6 +728,10 @@ ifdef ASCIIDOC8 export ASCIIDOC8 endif +ifdef NO_HARDLINKS + export NO_HARDLINKS +endif + # Shell quote (do not use $(call) to accommodate ancient setups); SHA1_HEADER_SQ = $(subst ','\'',$(SHA1_HEADER)) @@ -799,6 +807,7 @@ $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \ -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \ -e 's/@@NO_CURL@@/$(NO_CURL)/g' \ + -e 's/@@NO_HARDLINKS@@/$(NO_HARDLINKS)/g' \ $@.sh >$@+ && \ chmod +x $@+ && \ mv $@+ $@ diff --git a/git-clone.sh b/git-clone.sh index 2c0164aafe..72435b03aa 100644 --- a/git-clone.sh +++ b/git-clone.sh @@ -99,6 +99,7 @@ origin_override= use_separate_remote=t depth= no_progress= +test "@@NO_HARDLINKS@@" && use_local_hardlink=no test -t 1 || no_progress=--no-progress while case "$#,$1" in @@ -109,7 +110,9 @@ while *,--na|*,--nak|*,--nake|*,--naked|\ *,-b|*,--b|*,--ba|*,--bar|*,--bare) bare=yes ;; *,-l|*,--l|*,--lo|*,--loc|*,--loca|*,--local) - use_local_hardlink=yes ;; + (test "@@NO_HARDLINKS@@" && + echo >&2 "Warning: -l asked but hardlinks are not supported") || + use_local_hardlink=yes ;; *,--no-h|*,--no-ha|*,--no-har|*,--no-hard|*,--no-hardl|\ *,--no-hardli|*,--no-hardlin|*,--no-hardlink|*,--no-hardlinks) use_local_hardlink=no ;; diff --git a/t/Makefile b/t/Makefile index f8e396c108..2b808f96bb 100644 --- a/t/Makefile +++ b/t/Makefile @@ -18,6 +18,10 @@ ifdef NO_SYMLINKS GIT_TEST_OPTS += --no-symlinks endif +ifdef NO_HARDLINKS + GIT_TEST_OPTS += --no-hardlinks +endif + all: $(T) clean $(T): diff --git a/t/t5701-clone-local.sh b/t/t5701-clone-local.sh index a3026ec4fc..d2f55ebfbc 100755 --- a/t/t5701-clone-local.sh +++ b/t/t5701-clone-local.sh @@ -3,6 +3,13 @@ test_description='test local clone' . ./test-lib.sh +if test "$no_hardlinks" +then + say 'Hard links not supported, skipping tests.' + test_done + exit +fi + D=`pwd` test_expect_success 'preparing origin repository' ' diff --git a/t/test-lib.sh b/t/test-lib.sh index 6081d172ab..143d95daca 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -89,6 +89,8 @@ do shift ;; --no-symlinks) no_symlinks=t; shift ;; + --no-hardlinks) + no_hardlinks=t; shift ;; *) break ;; esac