Quantcast

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

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Andreas Färber
BFS does not support hardlinks, so suppress the resulting error  
messages.

Signed-off-by: Andreas Faerber <[hidden email]>
Acked-by: Ingo Weinhold <[hidden email]>
Acked-by: Scott McCreary <[hidden email]>
---
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


--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Junio C Hamano
Andreas Färber <[hidden email]> 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 <[hidden email]>
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 <[hidden email]>
Signed-off-by: Junio C Hamano <[hidden email]>
---
 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 [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Andreas Färber

Am 17.08.2008 um 13:03 schrieb Junio C Hamano:

> Andreas Färber <[hidden email]> 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Junio C Hamano
Andreas Färber <[hidden email]> writes:

> Am 17.08.2008 um 13:03 schrieb Junio C Hamano:
>
>> Andreas Färber <[hidden email]> 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.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH] Makefile: always provide a fallback when hardlinks fail

Andreas Färber
In reply to this post by Junio C Hamano

Am 17.08.2008 um 13:03 schrieb Junio C Hamano:

> Andreas Färber <[hidden email]> 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 <[hidden email]>
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 <[hidden email]>
---
  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





0001-Makefile-always-provide-a-fallback-when-hardlinks-f.patch (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH] Makefile: always provide a fallback when hardlinks fail

Junio C Hamano
Andreas Färber <[hidden email]> writes:

> From: Andreas Faerber <[hidden email]>
> 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 <[hidden email]>
> ---
>  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.

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