summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 69e7491)
raw | patch | inline | side by side (parent: 69e7491)
author | Junio C Hamano <gitster@pobox.com> | |
Mon, 3 Dec 2007 07:55:23 +0000 (23:55 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 3 Dec 2007 07:55:23 +0000 (23:55 -0800) |
Normally, it should not be allowed to generate an empty commit. A merge
commit generated with git 'merge -s ours' does not change the tree (along
the first parent), but merges are not "empty" even if they do not change
the tree. Hence, we should be careful not to forbid this case.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
commit generated with git 'merge -s ours' does not change the tree (along
the first parent), but merges are not "empty" even if they do not change
the tree. Hence, we should be careful not to forbid this case.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-commit.c | patch | blob | history |
diff --git a/builtin-commit.c b/builtin-commit.c
index f37a90f078b3e952830abe7ddb83599df2352eff..6c2dc390c451d5942521ddef9f046c5f98097dc3 100644 (file)
--- a/builtin-commit.c
+++ b/builtin-commit.c
return git_status_config(k, v);
}
+static int is_a_merge(const unsigned char *sha1)
+{
+ struct commit *commit = lookup_commit(sha1);
+ if (!commit || parse_commit(commit))
+ die("could not parse HEAD commit");
+ return !!(commit->parents && commit->parents->next);
+}
+
static const char commit_utf8_warn[] =
"Warning: commit message does not conform to UTF-8.\n"
"You may want to amend it after fixing the message, or set the config\n"
return 1;
}
- if (!prepare_log_message(index_file, prefix) && !in_merge) {
+ if (!prepare_log_message(index_file, prefix) && !in_merge &&
+ !(amend && is_a_merge(head_sha1))) {
run_status(stdout, index_file, prefix);
rollback_index_files();
unlink(commit_editmsg);