diff options
author | Junio C Hamano <gitster@pobox.com> | 2007-12-08 23:23:20 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2007-12-09 00:55:55 -0800 |
commit | 740001a5780a12972c83c99f25c49c8d8cebdb43 (patch) | |
tree | 228d6f0b9401aeea2e83bbcaf320edda42029e8f /builtin-commit.c | |
parent | Documentation: fix --no-verify documentation for "git commit" (diff) | |
download | tgif-740001a5780a12972c83c99f25c49c8d8cebdb43.tar.xz |
Fix commit-msg hook to allow editing
The old git-commit.sh script allowed the commit-msg hook to not only
prevent a commit from proceding, but also to edit the commit message
on the fly and allow it to proceed. So here we teach builtin-commit
to do the same.
This is based on Wincent's patch, but redone with a clarified logic.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-commit.c')
-rw-r--r-- | builtin-commit.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/builtin-commit.c b/builtin-commit.c index 2032ca314c..30a9debcda 100644 --- a/builtin-commit.c +++ b/builtin-commit.c @@ -787,16 +787,17 @@ int cmd_commit(int argc, const char **argv, const char *prefix) char index[PATH_MAX]; const char *env[2] = { index, NULL }; snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", index_file); - launch_editor(git_path(commit_editmsg), &sb, env); - } else if (strbuf_read_file(&sb, git_path(commit_editmsg), 0) < 0) { - rollback_index_files(); - die("could not read commit message"); + launch_editor(git_path(commit_editmsg), NULL, env); } if (!no_verify && run_hook(index_file, "commit-msg", git_path(commit_editmsg))) { rollback_index_files(); exit(1); } + if (strbuf_read_file(&sb, git_path(commit_editmsg), 0) < 0) { + rollback_index_files(); + die("could not read commit message"); + } /* Truncate the message just before the diff, if any. */ p = strstr(sb.buf, "\ndiff --git a/"); |