{"thread":{"id":"7139","subject":"[PATCH] Catch write_ref_sha1 failure in receive-pack","startedAt":"2007-03-07T17:04:24Z","lastAt":"2007-03-07T17:04:24Z","messageCount":1,"participants":["Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"36556","messageId":"20070307170424.GA27980@spearce.org","threadId":"7139","inReplyTo":null,"subject":"[PATCH] Catch write_ref_sha1 failure in receive-pack","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-03-07T17:04:24Z","receivedAt":"2007-03-07T17:04:24Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"This failure to catch the failure of write_ref_sha1 was noticed\nby Bill Lear.  The ref will not update if the log file could not\nbe appended to (due to file permissions problems).  Such a failure\nshould be flagged as a failure to update the ref, so that the client\nknows the push did not succeed.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n receive-pack.c |    5 ++++-\n 1 files changed, 4 insertions(+), 1 deletions(-)\n\ndiff --git a/receive-pack.c b/receive-pack.c\nindex 7f1dcc0..dda9854 100644\n--- a/receive-pack.c\n+++ b/receive-pack.c\n@@ -158,7 +158,10 @@ static int update(struct command *cmd)\n \t\t\tcmd->error_string = \"failed to lock\";\n \t\t\treturn error(\"failed to lock %s\", name);\n \t\t}\n-\t\twrite_ref_sha1(lock, new_sha1, \"push\");\n+\t\tif (write_ref_sha1(lock, new_sha1, \"push\")) {\n+\t\t\tcmd->error_string = \"failed to write\";\n+\t\t\treturn -1; /* error() already called */\n+\t\t}\n \t\tfprintf(stderr, \"%s: %s -> %s\\n\", name, old_hex, new_hex);\n \t}\n \treturn 0;\n-- \n1.5.0.3.895.g09890\n"}]}