login
Header Space

 
 

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

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Daniel Barkalow <barkalow@...>
Cc: Git Mailing List <git@...>, Johannes Schindelin <Johannes.Schindelin@...>
Date: Tuesday, May 20, 2008 - 12:45 pm

Brandon Casey wrote:

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) {
+				    	option_no_hardlinks = 1;
+					goto FALLBACK_TO_COPY;
+				}
 				die("failed to create link %s\n", dest);
+			}
 		}
 	}
 }


--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
builtin-clone does not fallback to copy when link fails, Brandon Casey, (Tue May 20, 12:28 pm)
Re: builtin-clone does not fallback to copy when link fails, Brandon Casey, (Tue May 20, 12:45 pm)
Re: builtin-clone does not fallback to copy when link fails, Daniel Barkalow, (Tue May 20, 2:16 pm)
Re: builtin-clone does not fallback to copy when link fails, Johannes Schindelin, (Tue May 20, 5:48 pm)
speck-geostationary