sha1_file: link() returns -1 on failure, not errno
5723fe7 (Avoid cross-directory renames and linking on object creation, 2008-06-14) changed the call to use link() directly instead of through a custom wrapper, but forgot that it returns 0 or -1, not 0 or errno. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Thomas Rast committed
Sep 19, 2008 at 00:24 UTC
e32c0a9c38a126c9eb8ff8f2fdc1fb8875400bbe
1 file changed
+3
-1
sha1_file.c
+3
-1
@@ -2136,7 +2136,9 @@ static void write_sha1_file_prepare(const void *buf, unsigned long len,
2136
*/
2137
int move_temp_to_file(const char *tmpfile, const char *filename)
2138
{
2139
- int ret = link(tmpfile, filename);
2139
+ int ret = 0;
2140
+ if (link(tmpfile, filename))
2141
+ ret = errno;
2142
2143
/*
2144
* Coda hack - coda doesn't like cross-directory links,