Re: [PATCH 6/6] Always provide a fallback when hardlinks fail

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Andreas Färber <andreas.faerber@xxxxxx> writes:

> BFS does not support hardlinks, so suppress the resulting error
> messages.

Hmm, this is not specific to BFS.  I would have preferred if you brought
up much earlier.

Your patch seems to be whitespace damaged.  Here is an alternative.

Note.

We currently install $(bindir)/git to $(gitexecdir)/git, make hardlinks to
"git-<cmd>" from "git" inside $(gitexecdir), and then finally remove "git"
in $(gitexecdir).

We could avoid this ugliness by:

 (1) install "$(gitexecdir)/git-add" (or any other single built-in) by
     trying hardlink "$(bindir)/git", and if it fails by copying;

 (2) for the rest of built-ins, install "$(gitexecdir)/git-<cmd>" by trying
     ln "$(gitexecdir)/git-add" "$(gitexecdir)/git-<cmd>", then
     ln -s "git-add" "$(gitexecdir)/git-<cmd>", then finally
     cp "$(gitexecdir)/git-add" "$(gitexecdir)/git-<cmd>".

That is not what I did, but it should be the right thing to do.  It is
already very late in the release cycle, and this whole thing can be done
after 1.6.0 final; we do not have to hurry.

---
From: Andreas Färber <andreas.faerber@xxxxxx>
Date: Sun, 17 Aug 2008 11:00:51 +0200
Subject: [PATCH] Makefile: always provide a fallback when hardlinks fail

We make hardlinks from "git" to "git-<cmd>" built-ins and have been
careful to avoid cross-device links when linking "git-<cmd>" 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.

While at it, avoid 100+ error messages from hardlink failures when we are
going to fall back to "cp" by redirecting the standard error to /dev/null.

Signed-off-by: Andreas Färber <andreas.faerber@xxxxxx>
Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx>
---
 Makefile |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index 53ab4b5..53112bb 100644
--- a/Makefile
+++ b/Makefile
@@ -1098,7 +1098,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
 
@@ -1365,10 +1368,12 @@ endif
 	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"; \
+		$(RM) "$$execdir/git$X" && \
+		ln "$$bindir/git$X" "$$execdir/git$X" 2>/dev/null || \
+		ln -s "$$bindir/git$X" "$$execdir/git$X" 2>/dev/null || \
+		cp "$$bindir/git$X" "$$execdir/git$X" || exit; \
 	fi && \
-	{ $(foreach p,$(BUILT_INS), $(RM) "$$execdir/$p" && ln "$$execdir/git$X" "$$execdir/$p" ;) } && \
+	{ $(foreach p,$(BUILT_INS), $(RM) "$$execdir/$p" && ln "$$execdir/git$X" "$$execdir/$p" 2>/dev/null || cp "$$execdir/git$X" "$$execdir/$p" || exit;) } && \
 	if test "z$$bindir" != "z$$execdir"; \
 	then \
 		$(RM) "$$execdir/git$X"; \
-- 
1.6.0.rc3.22.g053f



--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux