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

[PATCH 1/2] commit: extract commit_index_files_or_die() helper

From
Harald Nordgren via GitGitGadget <gitgitgadget@gmail.com>
Date
Jun 13, 2026, 09:16 UTC
Message-ID
<ddb720a8bded60b6efa35e571dff0e23ffb7b1a6.1781342189.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.2334.git.git.1781342189.gitgitgadget@gmail.com>
From: Harald Nordgren <haraldnordgren@gmail.com>

A later change adds a second caller that commits the index lock and dies on failure, so wrap that into a helper to avoid duplicating its message.

No functional change intended.
Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
---
 builtin/commit.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/builtin/commit.c b/builtin/commit.c
index 28f6174503..1a51450660 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -248,6 +248,14 @@ static int commit_index_files(void)
 	return err;
 }
 
+static void commit_index_files_or_die(void)
+{
+	if (commit_index_files())
+		die(_("repository has been updated, but unable to write\n"
+		      "new index file. Check that disk is not full and quota is\n"
+		      "not exceeded, and then \"git restore --staged :/\" to recover."));
+}
+
 /*
  * Take a union of paths in the index and the named tree (typically, "HEAD"),
  * and return the paths that match the given pattern in list.
@@ -1954,10 +1962,7 @@ int cmd_commit(int argc,
 	unlink(git_path_merge_mode(the_repository));
 	unlink(git_path_squash_msg(the_repository));
 
-	if (commit_index_files())
-		die(_("repository has been updated, but unable to write\n"
-		      "new index file. Check that disk is not full and quota is\n"
-		      "not exceeded, and then \"git restore --staged :/\" to recover."));
+	commit_index_files_or_die();
 
 	git_test_write_commit_graph_or_die(the_repository->objects->sources);
 
-- 
gitgitgadget
Previous: Harald Nordgren via GitGitGadgetNext: Harald Nordgren via GitGitGadget
Message 2 of 7 in “commit: preserve commit hash on a no-op amend”
  1. 0/2 commit: preserve commit hash on a no-op amendHarald Nordgren via GitGitGadget, Jun 13, 2026
  2. 1/2 commit: extract commit_index_files_or_die() helperHarald Nordgren via GitGitGadget, Jun 13, 2026
  3. 2/2 commit: keep the commit on a no-op amendHarald Nordgren via GitGitGadget, Jun 13, 2026
  4. Johannes SixtJun 13, 2026
  5. Ben KnobleJun 13, 2026
  6. Junio C HamanoJun 13, 2026
  7. Harald NordgrenJun 13, 2026

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.