summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: aa6da6c)
raw | patch | inline | side by side (parent: aa6da6c)
author | Junio C Hamano <gitster@pobox.com> | |
Sun, 9 Dec 2007 07:23:20 +0000 (23:23 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 9 Dec 2007 08:55:55 +0000 (00:55 -0800) |
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>
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>
builtin-commit.c | patch | blob | history | |
builtin-tag.c | patch | blob | history |
diff --git a/builtin-commit.c b/builtin-commit.c
index 2032ca314c1c7d9b6fd45128bb30bfe2c36f1792..30a9debcda9fc478571590fe45dc8647cef434fe 100644 (file)
--- a/builtin-commit.c
+++ b/builtin-commit.c
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/");
diff --git a/builtin-tag.c b/builtin-tag.c
index 729389bbd6120e4b395fbc6f916f8d13965191d6..9f966fc8837ee84c6d83825f0036e40997fec5f2 100644 (file)
--- a/builtin-tag.c
+++ b/builtin-tag.c
die("There was a problem with the editor %s.", editor);
}
+ if (!buffer)
+ return;
if (strbuf_read_file(buffer, path, 0) < 0)
die("could not read message file '%s': %s",
path, strerror(errno));