Skip to content

Commit e32c0a9

Browse files
trastgitster
authored andcommitted
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>
1 parent b99b5b4 commit e32c0a9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

sha1_file.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2136,7 +2136,9 @@ static void write_sha1_file_prepare(const void *buf, unsigned long len,
21362136
*/
21372137
int move_temp_to_file(const char *tmpfile, const char *filename)
21382138
{
2139-
int ret = link(tmpfile, filename);
2139+
int ret = 0;
2140+
if (link(tmpfile, filename))
2141+
ret = errno;
21402142

21412143
/*
21422144
* Coda hack - coda doesn't like cross-directory links,

0 commit comments

Comments
 (0)