git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Catch write_ref_sha1 failure in receive-pack

From
Shawn O. Pearce <spearce@spearce.org>
Date
Mar 7, 2007, 17:04 UTC
Message-ID
<20070307170424.GA27980@spearce.org>

This failure to catch the failure of write_ref_sha1 was noticed by Bill Lear. The ref will not update if the log file could not be appended to (due to file permissions problems). Such a failure should be flagged as a failure to update the ref, so that the client knows the push did not succeed.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 receive-pack.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/receive-pack.c b/receive-pack.c
index 7f1dcc0..dda9854 100644
--- a/receive-pack.c
+++ b/receive-pack.c
@@ -158,7 +158,10 @@ static int update(struct command *cmd)
 			cmd->error_string = "failed to lock";
 			return error("failed to lock %s", name);
 		}
-		write_ref_sha1(lock, new_sha1, "push");
+		if (write_ref_sha1(lock, new_sha1, "push")) {
+			cmd->error_string = "failed to write";
+			return -1; /* error() already called */
+		}
 		fprintf(stderr, "%s: %s -> %s\n", name, old_hex, new_hex);
 	}
 	return 0;
-- 
1.5.0.3.895.g09890
Message 1 of 1 in “Catch write_ref_sha1 failure in receive-pack”
  1. Catch write_ref_sha1 failure in receive-packShawn O. Pearce, Mar 7, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.