git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: builtin-clone does not fallback to copy when link fails

From
Brandon Casey <casey@nrlssc.navy.mil>
Date
May 20, 2008, 17:22 UTC
Message-ID
<huU-0mKnZACgQMuzg8VRUnBz_T6J3OdrjM9uWBVOZPtcbOk9EkBYlA@cipher.nrlssc.navy.mil>
In-Reply-To
<C6tFzFdDycYRRcjxtVG00CVX-Nsu7-UblPCaZmTxmWIUTFAsgReYbQ@cipher.nrlssc.navy.mil>
Brandon Casey wrote:
Show 27 quoted lines
> 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.
> 
> Something like this (if not too ugly) might do the trick:
> 
> diff --git a/builtin-clone.c b/builtin-clone.c
> index 8713128..1062371 100644
> --- a/builtin-clone.c
> +++ b/builtin-clone.c
> @@ -208,11 +208,17 @@ 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) {
> +FALLBACK_TO_COPY:
>  			if (copy_file(dest, src, 0666))
>  				die("failed to copy file to %s\n", dest);
>  		} else {
> -			if (link(src, dest))
> +			if (link(src, dest)) {
> +				if (errno == EXDEV && !option_local) {
Maybe EPERM should be tested also.
Or maybe it should be simplified to:
	if (!option_local)
		goto FALLBACK_TO_COPY;
-brandon
Previous: Brandon CaseyNext: Daniel Barkalow
Message 3 of 6 in “builtin-clone does not fallback to copy when link fails”
  1. Brandon CaseyMay 20, 2008
  2. Brandon CaseyMay 20, 2008
  3. Brandon CaseyMay 20, 2008
  4. Daniel BarkalowMay 20, 2008
  5. Brandon CaseyMay 20, 2008
  6. Johannes SchindelinMay 20, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.