Skip to content

Commit

Permalink
sha1_file: link() returns -1 on failure, not errno
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Thomas Rast authored and Junio C Hamano committed Sep 19, 2008
1 parent b99b5b4 commit e32c0a9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sha1_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -2136,7 +2136,9 @@ static void write_sha1_file_prepare(const void *buf, unsigned long len,
*/
int move_temp_to_file(const char *tmpfile, const char *filename)
{
int ret = link(tmpfile, filename);
int ret = 0;
if (link(tmpfile, filename))
ret = errno;

/*
* Coda hack - coda doesn't like cross-directory links,
Expand Down

0 comments on commit e32c0a9

Please sign in to comment.