[PATCH 1/2] commit: extract commit_index_files_or_die() helper
From: Harald Nordgren via GitGitGadget <hidden>
Date: 2026-06-13 09:16:34
Subsystem:
the rest · Maintainer:
Linus Torvalds
From: Harald Nordgren <redacted> 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 <redacted> --- 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