From: Daniel Barkalow Date: Tue, 20 May 2008 18:15:14 +0000 (-0400) Subject: clone: fall back to copying if hardlinking fails X-Git-Tag: v1.5.6-rc0~5^2~3 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=fdabc242f465771116e08d1ea3737fdb7453b2f1;p=git.git clone: fall back to copying if hardlinking fails Note that it stops trying hardlinks if any fail. Signed-off-by: Daniel Barkalow Signed-off-by: Junio C Hamano --- diff --git a/builtin-clone.c b/builtin-clone.c index 8936a5181..2a3f6732f 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); } closedir(dir); }