clone: fall back to copying if hardlinking fails

Note that it stops trying hardlinks if any fail.

Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Daniel Barkalow 2008-05-20 14:15:14 -04:00 committed by Junio C Hamano
parent 689ef4d42e
commit fdabc242f4
1 changed files with 7 additions and 5 deletions

View File

@ -207,13 +207,15 @@ static void copy_or_link_directory(char *src, char *dest)


if (unlink(dest) && errno != ENOENT) if (unlink(dest) && errno != ENOENT)
die("failed to unlink %s\n", dest); die("failed to unlink %s\n", dest);
if (option_no_hardlinks) { if (!option_no_hardlinks) {
if (copy_file(dest, src, 0666)) if (!link(src, dest))
die("failed to copy file to %s\n", dest); continue;
} else { if (option_local)
if (link(src, dest))
die("failed to create link %s\n", dest); 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); closedir(dir);
} }