git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: git@vger.kernel.org
Subject: Re: Octopus merge: unique (?) to git, but is it useful?
Date: Mon, 02 Jun 2008 22:17:42 -0700	[thread overview]
Message-ID: <7vskvv3xmx.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <7v3anv5fy3.fsf@gitster.siamese.dyndns.org> (Junio C. Hamano's message of "Mon, 02 Jun 2008 20:56:52 -0700")

Junio C Hamano <gitster@pobox.com> writes:

> Having said that, I think what is happening is that the final set of
> "other parents" is computed inside git-merge out of MERGE_HEAD and that is
> usually what is recorded in the resulting merge, but if the merge results
> in a conflict with manual resolution, that information is not given to the
> final "git commit".  The resulting commit records the parents out of HEAD
> and MERGE_HEAD.  I do not think this part has changed from scripted
> version of git-commit.

Sorry, my thinko.

The scripted version obviously used commit-tree to omit the duplicated
parent.  Perhaps we can do something like this.

-- >8 --
commit: drop duplicated parents

The scripted version of git-commit internally used git-commit-tree which
omitted duplicated parents given from the command line.  This prevented a
nonsensical octopus merge from getting created even when you said "git
merge A B" while you are already on branch A.

However, when git-commit was rewritten in C, this sanity check was lost.
This resurrects it.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin-commit.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/builtin-commit.c b/builtin-commit.c
index b294c1f..1d8d208 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -883,10 +883,19 @@ static void add_parent(struct strbuf *sb, const unsigned char *sha1)
 {
 	struct object *obj = parse_object(sha1);
 	const char *parent = sha1_to_hex(sha1);
+	const char *cp;
+
 	if (!obj)
 		die("Unable to find commit parent %s", parent);
 	if (obj->type != OBJ_COMMIT)
 		die("Parent %s isn't a proper commit", parent);
+	cp = strstr(sb->buf, parent);
+	if (cp &&
+	    sb->buf + 8 <= cp && !memcmp(cp - 8, "\nparent ", 8) &&
+	    cp[40] == '\n') {
+		error("duplicate parent %s ignored", parent);
+		return;
+	}
 	strbuf_addf(sb, "parent %s\n", parent);
 }
 

  reply	other threads:[~2008-06-03  5:18 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-03  1:14 Octopus merge: unique (?) to git, but is it useful? Jakub Narebski
2008-06-03  2:05 ` Linus Torvalds
2008-06-03  3:56   ` Junio C Hamano
2008-06-03  5:17     ` Junio C Hamano [this message]
2008-06-03  5:28       ` Johannes Schindelin
2008-06-03  5:42         ` Junio C Hamano
2008-06-03  8:31           ` Johannes Schindelin
2008-06-03 10:40       ` SZEDER Gábor
2008-06-03 19:30         ` Junio C Hamano
2008-06-03 20:39           ` SZEDER Gábor
2008-06-03 22:08             ` Junio C Hamano
2008-06-03 23:10               ` SZEDER Gábor
2008-06-04  0:35                 ` Jeff King
2008-06-04  1:02                 ` Junio C Hamano
2008-06-03 14:40     ` Linus Torvalds
2008-06-03 23:11       ` Miklos Vajna
2008-06-04  0:33         ` Junio C Hamano
2008-06-03  4:29   ` Junio C Hamano
2008-06-03  6:39     ` Jakub Narebski
2008-06-03  7:11       ` Junio C Hamano
2008-06-03  7:32   ` Jakub Narebski
2008-06-03  7:53     ` Junio C Hamano
2008-06-03 19:54     ` Linus Torvalds
2008-06-03 20:27       ` Commit annotations (was:: Octopus merge: unique (?) to git, but is it useful?) Jakub Narebski
2008-06-03 20:33         ` Johannes Schindelin
2008-06-03 23:59           ` Johan Herland
2008-06-03  2:16 ` Octopus merge: unique (?) to git, but is it useful? Daniel Villeneuve
2008-06-03 10:06 ` Matthieu Moy
2008-06-03 11:27   ` Jakub Narebski
2008-06-03 11:53     ` Matthieu Moy

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=7vskvv3xmx.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /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).