Re: Octopus merge: unique (?) to git, but is it useful?

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Linus Torvalds <torvalds@...>
Cc: <git@...>
Date: Tuesday, June 3, 2008 - 1:17 am

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


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);
 }
 
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Octopus merge: unique (?) to git, but is it useful?, Jakub Narebski, (Mon Jun 2, 9:14 pm)
Re: Octopus merge: unique (?) to git, but is it useful?, Jakub Narebski, (Tue Jun 3, 7:27 am)
Re: Octopus merge: unique (?) to git, but is it useful?, Daniel Villeneuve, (Mon Jun 2, 10:16 pm)
Re: Octopus merge: unique (?) to git, but is it useful?, Linus Torvalds, (Mon Jun 2, 10:05 pm)
Re: Octopus merge: unique (?) to git, but is it useful?, Jakub Narebski, (Tue Jun 3, 3:32 am)
Re: Octopus merge: unique (?) to git, but is it useful?, Linus Torvalds, (Tue Jun 3, 3:54 pm)
Re: Commit annotations (was:: Octopus merge: unique (?) to g..., Johannes Schindelin, (Tue Jun 3, 4:33 pm)
Re: Octopus merge: unique (?) to git, but is it useful?, Junio C Hamano, (Tue Jun 3, 3:53 am)
Re: Octopus merge: unique (?) to git, but is it useful?, Junio C Hamano, (Tue Jun 3, 12:29 am)
Re: Octopus merge: unique (?) to git, but is it useful?, Jakub Narebski, (Tue Jun 3, 2:39 am)
Re: Octopus merge: unique (?) to git, but is it useful?, Junio C Hamano, (Tue Jun 3, 3:11 am)
Re: Octopus merge: unique (?) to git, but is it useful?, Junio C Hamano, (Mon Jun 2, 11:56 pm)
Re: Octopus merge: unique (?) to git, but is it useful?, Linus Torvalds, (Tue Jun 3, 10:40 am)
Re: Octopus merge: unique (?) to git, but is it useful?, Junio C Hamano, (Tue Jun 3, 8:33 pm)
Re: Octopus merge: unique (?) to git, but is it useful?, Junio C Hamano, (Tue Jun 3, 1:17 am)
Re: Octopus merge: unique (?) to git, but is it useful?, Junio C Hamano, (Tue Jun 3, 3:30 pm)
Re: Octopus merge: unique (?) to git, but is it useful?, Junio C Hamano, (Tue Jun 3, 6:08 pm)
Re: Octopus merge: unique (?) to git, but is it useful?, Junio C Hamano, (Tue Jun 3, 9:02 pm)
Re: Octopus merge: unique (?) to git, but is it useful?, Johannes Schindelin, (Tue Jun 3, 1:28 am)
Re: Octopus merge: unique (?) to git, but is it useful?, Junio C Hamano, (Tue Jun 3, 1:42 am)
Re: Octopus merge: unique (?) to git, but is it useful?, Johannes Schindelin, (Tue Jun 3, 4:31 am)