* [PATCH 6/6] Always provide a fallback when hardlinks fail @ 2008-08-17 9:00 Andreas Färber 2008-08-17 11:03 ` Junio C Hamano 0 siblings, 1 reply; 6+ messages in thread From: Andreas Färber @ 2008-08-17 9:00 UTC (permalink / raw) To: git, gitster BFS does not support hardlinks, so suppress the resulting error messages. Signed-off-by: Andreas Faerber <andreas.faerber@web.de> Acked-by: Ingo Weinhold <ingo_weinhold@gmx.de> Acked-by: Scott McCreary <scottmc2@gmail.com> --- In one place cp was already used as fallback, so I went that route. Personally I would also be okay with symlinks as alternative. Makefile | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 3daf9ac..7dc4bbd 100644 --- a/Makefile +++ b/Makefile @@ -1106,7 +1106,7 @@ 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 || cp git$X $@ common-cmds.h: ./generate-cmdlist.sh command-list.txt @@ -1373,10 +1373,10 @@ endif execdir=$$(cd '$(DESTDIR_SQ)$(gitexec_instdir_SQ)' && pwd) && \ if test "z$$bindir" != "z$$execdir"; \ then \ - ln -f "$$bindir/git$X" "$$execdir/git$X" || \ + ln -f "$$bindir/git$X" "$$execdir/git$X" 2>/dev/null || \ cp "$$bindir/git$X" "$$execdir/git$X"; \ 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" ;) } && \ if test "z$$bindir" != "z$$execdir"; \ then \ $(RM) "$$execdir/git$X"; \ -- 1.6.0.rc3.32.g8aaa ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 6/6] Always provide a fallback when hardlinks fail 2008-08-17 9:00 [PATCH 6/6] Always provide a fallback when hardlinks fail Andreas Färber @ 2008-08-17 11:03 ` Junio C Hamano 2008-08-17 12:14 ` Andreas Färber 2008-08-25 15:42 ` [PATCH] Makefile: always " Andreas Färber 0 siblings, 2 replies; 6+ messages in thread From: Junio C Hamano @ 2008-08-17 11:03 UTC (permalink / raw) To: Andreas Färber; +Cc: git Andreas Färber <andreas.faerber@web.de> 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@web.de> 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@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com> --- 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 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 6/6] Always provide a fallback when hardlinks fail 2008-08-17 11:03 ` Junio C Hamano @ 2008-08-17 12:14 ` Andreas Färber 2008-08-17 17:51 ` Junio C Hamano 2008-08-25 15:42 ` [PATCH] Makefile: always " Andreas Färber 1 sibling, 1 reply; 6+ messages in thread From: Andreas Färber @ 2008-08-17 12:14 UTC (permalink / raw) To: Junio C Hamano; +Cc: git Am 17.08.2008 um 13:03 schrieb Junio C Hamano: > Andreas Färber <andreas.faerber@web.de> 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. Right, it isn't. Do you mean earlier in time, or would you like me to reorder it in my v2 series? > 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"; \ Looks fine, I'll test it together with the other changes. Andreas ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 6/6] Always provide a fallback when hardlinks fail 2008-08-17 12:14 ` Andreas Färber @ 2008-08-17 17:51 ` Junio C Hamano 0 siblings, 0 replies; 6+ messages in thread From: Junio C Hamano @ 2008-08-17 17:51 UTC (permalink / raw) To: Andreas Färber; +Cc: git Andreas Färber <andreas.faerber@web.de> writes: > Am 17.08.2008 um 13:03 schrieb Junio C Hamano: > >> Andreas Färber <andreas.faerber@web.de> 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. > > Right, it isn't. Do you mean earlier in time, or would you like me to > reorder it in my v2 series? Sorry for being unclear. I edited the message a few times and this part came out quite differently as I intended. It should have read this way: Thanks for noticing (I would have preferred to hear about this a bit earlier, not before the release day). Anyhow, thanks for the patch again. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] Makefile: always provide a fallback when hardlinks fail 2008-08-17 11:03 ` Junio C Hamano 2008-08-17 12:14 ` Andreas Färber @ 2008-08-25 15:42 ` Andreas Färber 2008-08-25 21:36 ` Junio C Hamano 1 sibling, 1 reply; 6+ messages in thread From: Andreas Färber @ 2008-08-25 15:42 UTC (permalink / raw) To: Junio C Hamano; +Cc: git [-- Attachment #1: Type: text/plain, Size: 3880 bytes --] Am 17.08.2008 um 13:03 schrieb Junio C Hamano: > Andreas Färber <andreas.faerber@web.de> writes: > >> BFS does not support hardlinks, so suppress the resulting error >> messages. > > Hmm, this is not specific to BFS. [...] > > 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. I've tried to implement what you've outlined above. On Haiku this now results in symlinks within the build dir for the builtins including git-add, and in symlinks for all builtins but git- add in $prefix/libexec/git-core. --- From: Andreas Faerber <andreas.faerber@web.de> Date: Mon, 25 Aug 2008 17:33:03 +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. Instead of temporarily linking "git" to gitexecdir, directly link "git- add", falling back to "cp". Try hardlinking that as "git-<cmd>", 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 <andreas.faerber@web.de> --- Makefile | 22 +++++++++++----------- 1 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 7a6cbb6..fb4863c 100644 --- a/Makefile +++ b/Makefile @@ -1110,7 +1110,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 @@ -1371,16 +1374,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,$(patsubst git-add,,$(BUILT_INS)), $(RM) "$$execdir/ $p" && \ + ln "$$execdir/git-add$X" "$$execdir/$p" 2>/dev/null || \ + ln -s "$$execdir/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: -- 1.6.0.1.91.gaea6 [-- Attachment #2: 0001-Makefile-always-provide-a-fallback-when-hardlinks-f.patch --] [-- Type: application/octet-stream, Size: 2610 bytes --] From aea60501ba1651f7ba51de8381db5355d6df472b Mon Sep 17 00:00:00 2001 From: Andreas Faerber <andreas.faerber@web.de> Date: Mon, 25 Aug 2008 17:33:03 +0200 Subject: [PATCH] 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-<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. Instead of temporarily linking "git" to gitexecdir, directly link "git-add", falling back to "cp". Try hardlinking that as "git-<cmd>", 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 <andreas.faerber@web.de> --- Makefile | 22 +++++++++++----------- 1 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 7a6cbb6..fb4863c 100644 --- a/Makefile +++ b/Makefile @@ -1110,7 +1110,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 @@ -1371,16 +1374,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,$(patsubst git-add,,$(BUILT_INS)), $(RM) "$$execdir/$p" && \ + ln "$$execdir/git-add$X" "$$execdir/$p" 2>/dev/null || \ + ln -s "$$execdir/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: -- 1.6.0.1.91.gaea6 [-- Attachment #3: Type: text/plain, Size: 2 bytes --] ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] Makefile: always provide a fallback when hardlinks fail 2008-08-25 15:42 ` [PATCH] Makefile: always " Andreas Färber @ 2008-08-25 21:36 ` Junio C Hamano 0 siblings, 0 replies; 6+ messages in thread From: Junio C Hamano @ 2008-08-25 21:36 UTC (permalink / raw) To: Andreas Färber; +Cc: git Andreas Färber <andreas.faerber@web.de> writes: > From: Andreas Faerber <andreas.faerber@web.de> > Date: Mon, 25 Aug 2008 17:33:03 +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. > > Instead of temporarily linking "git" to gitexecdir, directly link "git- > add", falling back to "cp". Try hardlinking that as "git-<cmd>", 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 <andreas.faerber@web.de> > --- > Makefile | 22 +++++++++++----------- > 1 files changed, 11 insertions(+), 11 deletions(-) > > diff --git a/Makefile b/Makefile > index 7a6cbb6..fb4863c 100644 > --- a/Makefile > +++ b/Makefile > @@ -1110,7 +1110,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 $@ Ok. > > common-cmds.h: ./generate-cmdlist.sh command-list.txt > > @@ -1371,16 +1374,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 && \ (mental note while reviewing the change) Outside context before this part we have installed "git$X" to $$bindir, and removed leftover "git-foo" without .exe on the platform where X=.exe. > + { $(RM) "$$execdir/git-add$X" && \ > + ln git-add$X "$$execdir/git-add$X" 2>/dev/null || \ > + cp git-add$X "$$execdir/git-add$X"; } && \ (mental note while reviewing the change) First, we install git-add$X to $$execdir, either hardlink or copy. > + { $(foreach p,$(patsubst git-add,,$(BUILT_INS)), $(RM) > "$$execdir/ > $p" && \ > + ln "$$execdir/git-add$X" "$$execdir/$p" 2>/dev/null || \ > + ln -s "$$execdir/git-add$X" "$$execdir/$p" 2>/dev/null || \ > + cp "$$execdir/git-add$X" "$$execdir/$p" || exit;) } && \ Nits. * Line-wrapped; * $(patsubst) is probably $(filter-out); (mental note while reviewing the change) Then we install the rest by linking, symlinking or copying git-add$X. We might want to do the "symlinking" to $$bindir/git$X instead, but other than that (and above two minor nits), this looks pretty good. Thanks, will try and apply. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-08-25 21:37 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-08-17 9:00 [PATCH 6/6] Always provide a fallback when hardlinks fail Andreas Färber 2008-08-17 11:03 ` Junio C Hamano 2008-08-17 12:14 ` Andreas Färber 2008-08-17 17:51 ` Junio C Hamano 2008-08-25 15:42 ` [PATCH] Makefile: always " Andreas Färber 2008-08-25 21:36 ` Junio C Hamano
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).