summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 885ed37)
raw | patch | inline | side by side (parent: 885ed37)
author | Junio C Hamano <gitster@pobox.com> | |
Thu, 20 Dec 2007 03:23:03 +0000 (19:23 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 20 Dec 2007 09:11:53 +0000 (01:11 -0800) |
The prepare_log_message() function serves two purposes:
- Prepares the commit log message template, to be given to the end
user;
- Return true if there is something committable;
7168624c3530d8c7ee32f930f8fb2ba302b9801f (Do not generate full commit
log message if it is not going to be used) cheated to omit the former
when we know the log message template is not going to be used. However,
its replacement logic to see if there is something committable was
botched. When amending, it should compare the index with the parent of
the HEAD, not the current HEAD. Otherwise you cannot run --amend to
fix only the message without changing the tree.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
- Prepares the commit log message template, to be given to the end
user;
- Return true if there is something committable;
7168624c3530d8c7ee32f930f8fb2ba302b9801f (Do not generate full commit
log message if it is not going to be used) cheated to omit the former
when we know the log message template is not going to be used. However,
its replacement logic to see if there is something committable was
botched. When amending, it should compare the index with the parent of
the HEAD, not the current HEAD. Otherwise you cannot run --amend to
fix only the message without changing the tree.
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 0a9101324f422e90651d612666a06a138d06507b..96410de55ddbc52eb116049b4f6a2792a5386cb4 100644 (file)
--- a/builtin-commit.c
+++ b/builtin-commit.c
if (no_edit) {
struct rev_info rev;
unsigned char sha1[40];
+ const char *parent = "HEAD";
fclose(fp);
if (get_sha1("HEAD", sha1) != 0)
return !!active_nr;
+ if (amend)
+ parent = "HEAD^1";
+
init_revisions(&rev, "");
rev.abbrev = 0;
- setup_revisions(0, NULL, &rev, "HEAD");
+ setup_revisions(0, NULL, &rev, parent);
DIFF_OPT_SET(&rev.diffopt, QUIET);
DIFF_OPT_SET(&rev.diffopt, EXIT_WITH_STATUS);
run_diff_index(&rev, 1 /* cached */);