git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Andreas Färber" <andreas.faerber@web.de>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Makefile: always provide a fallback when hardlinks fail
Date: Mon, 25 Aug 2008 14:36:20 -0700	[thread overview]
Message-ID: <7vej4cg4kr.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <D4374620-C6D8-4CB3-8A7D-C5449BB8E8D1@web.de> (Andreas Färber's message of "Mon, 25 Aug 2008 17:42:21 +0200")

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.

      reply	other threads:[~2008-08-25 21:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vej4cg4kr.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=andreas.faerber@web.de \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).