Git development
 help / color / mirror / Atom feed
From: Daniel Barkalow <barkalow@iabervon.org>
To: Brandon Casey <casey@nrlssc.navy.mil>
Cc: Git Mailing List <git@vger.kernel.org>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: Re: builtin-clone does not fallback to copy when link fails
Date: Tue, 20 May 2008 14:16:56 -0400 (EDT)	[thread overview]
Message-ID: <alpine.LNX.1.00.0805201311180.19665@iabervon.org> (raw)
In-Reply-To: <C6tFzFdDycYRRcjxtVG00CVX-Nsu7-UblPCaZmTxmWIUTFAsgReYbQ@cipher.nrlssc.navy.mil>

On Tue, 20 May 2008, Brandon Casey wrote:

> Brandon Casey wrote:
> > 
> > When cloning with the new builtin-clone, if the src repo is not
> > on the same disk as the dest repo, cloning fails. This is because
> > hard linking does not fall back to copying like the shell version
> > did.
> > 
> > The shell version also made a distinction between defaulting to
> > hard linking and an explicit request to hard link. In the latter
> > case it would not fall back to copying, but would die.

I think that the shell version's behavior changed at some point, too. I 
think I tried at some point to figure out exactly what the specified 
behavior was, and couldn't come up with anything that entirely matched.

> Something like this (if not too ugly) might do the trick:

I think that's good behavior, but it's kind of ugly. How about:

-----
commit 83afef6a159365c1b9a7a1961cb4c95df24fbcac
Author: Daniel Barkalow <barkalow@iabervon.org>
Date:   Tue May 20 14:15:14 2008 -0400

    Fall back to copying if hardlinking fails
    
    Note that it stops trying hardlinks if any fail.
    
    Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>

diff --git a/builtin-clone.c b/builtin-clone.c
index 8713128..42633ae 100644
--- a/builtin-clone.c
+++ b/builtin-clone.c
@@ -207,13 +207,15 @@ static void copy_or_link_directory(char *src, char *dest)
 
 		if (unlink(dest) && errno != ENOENT)
 			die("failed to unlink %s\n", dest);
-		if (option_no_hardlinks) {
-			if (copy_file(dest, src, 0666))
-				die("failed to copy file to %s\n", dest);
-		} else {
-			if (link(src, dest))
+		if (!option_no_hardlinks) {
+			if (!link(src, dest))
+				continue;
+			if (option_local)
 				die("failed to create link %s\n", dest);
+			option_no_hardlinks = 1;
 		}
+		if (copy_file(dest, src, 0666))
+			die("failed to copy file to %s\n", dest);
 	}
 }
 

  parent reply	other threads:[~2008-05-20 18:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-20 16:28 builtin-clone does not fallback to copy when link fails Brandon Casey
2008-05-20 16:45 ` Brandon Casey
2008-05-20 17:22   ` Brandon Casey
2008-05-20 18:16   ` Daniel Barkalow [this message]
2008-05-20 18:44     ` Brandon Casey
2008-05-20 21:48     ` Johannes Schindelin

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=alpine.LNX.1.00.0805201311180.19665@iabervon.org \
    --to=barkalow@iabervon.org \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=casey@nrlssc.navy.mil \
    --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