git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git-commit: exit non-zero if we fail to commit the index
@ 2008-01-17  0:07 Brandon Casey
  2008-01-17  1:13 ` Junio C Hamano
  0 siblings, 1 reply; 9+ messages in thread
From: Brandon Casey @ 2008-01-17  0:07 UTC (permalink / raw)
  To: Git Mailing List, Junio C Hamano

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---


Shouldn't we be doing this? I think if quiet is set,
then a failed rename will go undetected since we
won't enter print_summary to have lookup_commit fail.

rerere() die()'s on a failure, but also returns zero
if it can't create a lock file.

run_hook also is not checked for failure. I guess it
should at least print an error message on failure, but
I've never used hooks.

-brandon


 builtin-commit.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/builtin-commit.c b/builtin-commit.c
index a764053..d7db7b3 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -122,19 +122,23 @@ static void rollback_index_files(void)
 	}
 }
 
-static void commit_index_files(void)
+static int commit_index_files(void)
 {
+	int err = 0;
+
 	switch (commit_style) {
 	case COMMIT_AS_IS:
 		break; /* nothing to do */
 	case COMMIT_NORMAL:
-		commit_lock_file(&index_lock);
+		err = commit_lock_file(&index_lock);
 		break;
 	case COMMIT_PARTIAL:
-		commit_lock_file(&index_lock);
+		err = commit_lock_file(&index_lock);
 		rollback_lock_file(&false_lock);
 		break;
 	}
+
+	return err;
 }
 
 /*
@@ -912,7 +916,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 	unlink(git_path("MERGE_HEAD"));
 	unlink(git_path("MERGE_MSG"));
 
-	commit_index_files();
+	if (commit_index_files())
+		die("unable to write new_index file");
 
 	rerere();
 	run_hook(get_index_file(), "post-commit", NULL);
-- 
1.5.4.rc3.17.gb63a4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2008-01-23 20:49 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-17  0:07 [PATCH] git-commit: exit non-zero if we fail to commit the index Brandon Casey
2008-01-17  1:13 ` Junio C Hamano
2008-01-17  1:49   ` Brandon Casey
2008-01-17  2:11     ` Junio C Hamano
2008-01-22 19:26       ` Brandon Casey
2008-01-22 23:42         ` Junio C Hamano
2008-01-23 17:21           ` Brandon Casey
2008-01-23 20:01             ` Junio C Hamano
2008-01-23 20:47               ` Brandon Casey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).