git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Johannes Sixt <johannes.sixt@telecom.at>
Cc: krh@redhat.com, Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] git-commit: Allow to amend a merge commit that does not change the tree
Date: Sun, 02 Dec 2007 23:51:58 -0800	[thread overview]
Message-ID: <7vtzn0md0h.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <1196666690-22187-1-git-send-email-johannes.sixt@telecom.at> (Johannes Sixt's message of "Mon, 3 Dec 2007 08:24:50 +0100")

Johannes Sixt <johannes.sixt@telecom.at> writes:

> 	I haven't gotten around to write a test case for this scenario,
> 	so I'm sending out the fix alone, in order to draw attention
> 	to the issue and have builtin-commit fixed by its authors, if
> 	necessary ;)

Untested but something like this ought to do.

 builtin-commit.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/builtin-commit.c b/builtin-commit.c
index f37a90f..6c2dc39 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -676,6 +676,14 @@ int git_commit_config(const char *k, const char *v)
 	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"
@@ -701,7 +709,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 		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);

  reply	other threads:[~2007-12-03  7:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-03  7:24 [PATCH] git-commit: Allow to amend a merge commit that does not change the tree Johannes Sixt
2007-12-03  7:51 ` Junio C Hamano [this message]
2007-12-03  8:26   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vtzn0md0h.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=johannes.sixt@telecom.at \
    --cc=krh@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).