{"thread":{"id":"15581","subject":"[PATCH] sha1_file: link() returns -1 on failure, not errno","startedAt":"2008-09-18T22:24:46Z","lastAt":"2008-09-18T22:24:46Z","messageCount":1,"participants":["Thomas Rast"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"91076","messageId":"1221776686-13284-1-git-send-email-trast@student.ethz.ch","threadId":"15581","inReplyTo":null,"subject":"[PATCH] sha1_file: link() returns -1 on failure, not errno","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2008-09-18T22:24:46Z","receivedAt":"2008-09-18T22:24:46Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"5723fe7 changed the call to use link() directly instead of through a\ncustom wrapper, but forgot that it returns 0 or -1, not 0 or errno.\n\nSigned-off-by: Thomas Rast <trast@student.ethz.ch>\n\n---\n sha1_file.c |    4 +++-\n 1 files changed, 3 insertions(+), 1 deletions(-)\n\ndiff --git a/sha1_file.c b/sha1_file.c\nindex 9ee1ed1..aec81bb 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -2136,7 +2136,9 @@ static void write_sha1_file_prepare(const void *buf, unsigned long len,\n  */\n int move_temp_to_file(const char *tmpfile, const char *filename)\n {\n-\tint ret = link(tmpfile, filename);\n+\tint ret = 0;\n+\tif (link(tmpfile, filename))\n+\t\tret = errno;\n \n \t/*\n \t * Coda hack - coda doesn't like cross-directory links,\n-- \ntg: (97d7fee..) t/link-returns-minus1 (depends on: origin/master)\n"}]}