From 3e073dc561185d5ad2325cb012943020e068801e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Mon, 25 Aug 2008 17:33:03 +0200 Subject: Makefile: always provide a fallback when hardlinks fail MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We make hardlinks from "git" to "git-" built-ins and have been careful to avoid cross-device links when linking "git-" to gitexecdir. However, we were not prepared to deal with a build directory that is incapable of making hard links within itself. This patch corrects it. Instead of temporarily linking "git" to gitexecdir, directly link "git- add", falling back to "cp". Try hardlinking that as "git-", falling back to symlinks or "cp" on error. While at it, avoid 100+ error messages from hardlink failures when we are going to fall back to symlinks or "cp" by redirecting the standard error to /dev/null. Signed-off-by: Andreas Färber Signed-off-by: Junio C Hamano --- Makefile | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 2cef0187d1..588bf5aee5 100644 --- a/Makefile +++ b/Makefile @@ -1099,7 +1099,10 @@ help.o: help.c common-cmds.h GIT-CFLAGS '-DGIT_INFO_PATH="$(infodir_SQ)"' $< $(BUILT_INS): git$X - $(QUIET_BUILT_IN)$(RM) $@ && ln git$X $@ + $(QUIET_BUILT_IN)$(RM) $@ && \ + ln git$X $@ 2>/dev/null || \ + ln -s git$X $@ 2>/dev/null || \ + cp git$X $@ common-cmds.h: ./generate-cmdlist.sh command-list.txt @@ -1364,16 +1367,13 @@ ifneq (,$X) endif bindir=$$(cd '$(DESTDIR_SQ)$(bindir_SQ)' && pwd) && \ execdir=$$(cd '$(DESTDIR_SQ)$(gitexec_instdir_SQ)' && pwd) && \ - if test "z$$bindir" != "z$$execdir"; \ - then \ - ln -f "$$bindir/git$X" "$$execdir/git$X" || \ - cp "$$bindir/git$X" "$$execdir/git$X"; \ - fi && \ - { $(foreach p,$(BUILT_INS), $(RM) "$$execdir/$p" && ln "$$execdir/git$X" "$$execdir/$p" ;) } && \ - if test "z$$bindir" != "z$$execdir"; \ - then \ - $(RM) "$$execdir/git$X"; \ - fi && \ + { $(RM) "$$execdir/git-add$X" && \ + ln git-add$X "$$execdir/git-add$X" 2>/dev/null || \ + cp git-add$X "$$execdir/git-add$X"; } && \ + { $(foreach p,$(filter-out git-add,$(BUILT_INS)), $(RM) "$$execdir/$p" && \ + ln "$$execdir/git-add$X" "$$execdir/$p" 2>/dev/null || \ + ln -s "git-add$X" "$$execdir/$p" 2>/dev/null || \ + cp "$$execdir/git-add$X" "$$execdir/$p" || exit;) } && \ ./check_bindir "z$$bindir" "z$$execdir" "$$bindir/git-add$X" install-doc: -- cgit v1.2.1 From 4e3ae59ef63475411f4c073ba3a1478b1ef73b9a Mon Sep 17 00:00:00 2001 From: Alex Riesen Date: Thu, 28 Aug 2008 15:57:32 +0200 Subject: Fix use of hardlinks in "make install" The code failed to filter-out git-add properly on platforms were $X is not empty (ATM there is only one such a platform). Than it tried to create a hardlink to the file ($execdir/git-add) it just removed (because git-add is first in the BUILT_INS), so ln failed (but because stderr was redirected into /dev/null the error was never seen), and the whole install ended up using "ln -s" instead. Signed-off-by: Alex Riesen Signed-off-by: Junio C Hamano --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 588bf5aee5..b6df1e9d8b 100644 --- a/Makefile +++ b/Makefile @@ -1370,7 +1370,7 @@ endif { $(RM) "$$execdir/git-add$X" && \ ln git-add$X "$$execdir/git-add$X" 2>/dev/null || \ cp git-add$X "$$execdir/git-add$X"; } && \ - { $(foreach p,$(filter-out git-add,$(BUILT_INS)), $(RM) "$$execdir/$p" && \ + { $(foreach p,$(filter-out git-add$X,$(BUILT_INS)), $(RM) "$$execdir/$p" && \ ln "$$execdir/git-add$X" "$$execdir/$p" 2>/dev/null || \ ln -s "git-add$X" "$$execdir/$p" 2>/dev/null || \ cp "$$execdir/git-add$X" "$$execdir/$p" || exit;) } && \ -- cgit v1.2.1