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

[PATCH] Don't ignore a low-probability ref-pack write failure

From
Jim Meyering <jim@meyering.net>
Date
Jun 24, 2007, 19:13 UTC
Message-ID
<87d4zlyxmg.fsf@rho.meyering.net>

Without this, if the size of refs_file at that point is ever an exact multiple of BUFSIZ, then an EIO or ENOSPC error on the final write would not be diagnosed.

It's not worth worrying about EPIPE here. Although theoretically possible that someone kill this process with a manual SIGPIPE, it's not at all likely.

Signed-off-by: Jim Meyering <jim@meyering.net>
---
 builtin-pack-refs.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/builtin-pack-refs.c b/builtin-pack-refs.c
index 1952950..7584992 100644
--- a/builtin-pack-refs.c
+++ b/builtin-pack-refs.c
@@ -105,6 +105,8 @@ static int pack_refs(unsigned int flags)
 	fprintf(cbdata.refs_file, "# pack-refs with: peeled \n");

 	for_each_ref(handle_one_ref, &cbdata);
+	if (ferror(cbdata.refs_file))
+		die("failed to write ref-pack file");
 	if (fflush(cbdata.refs_file) || fsync(fd) || fclose(cbdata.refs_file))
 		die("failed to write ref-pack file (%s)", strerror(errno));
 	if (commit_lock_file(&packed) < 0)
Message 1 of 1 in “Don't ignore a low-probability ref-pack write failure”
  1. Don't ignore a low-probability ref-pack write failureJim Meyering, Jun 24, 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.