git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: Marco Costalba <mcostalba@gmail.com>,
	Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] Fix "git log --parent -m" from emitting duplicated parent info
Date: Sun, 08 Jul 2007 18:38:24 -0700	[thread overview]
Message-ID: <7vps32xsof.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <Pine.LNX.4.64.0707090220281.4248@racer.site> (Johannes Schindelin's message of "Mon, 9 Jul 2007 02:22:57 +0100 (BST)")

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> I only found this:
>
> http://thread.gmane.org/gmane.comp.version-control.git/29222

Thanks.  As it happens, the patch I just sent out is a moral
equivalent of your patch in that thread ;-)

We still may need to think about being careful upon --full-history
though.

Second try, this time not doing the simplification when --full-history
is given.

-- >8 --
[PATCH] remove duplicated parents after history simplification

When we simplify history due to path limits, the parents list
for a rewritten commit can end up having duplicates.  Instead of
filtering them out in the output codepath like earlier commit
88494423 did, remove them much earlier, when the parent
information actually gets rewritten.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---

 revision.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/revision.c b/revision.c
index 5184716..740e6a8 100644
--- a/revision.c
+++ b/revision.c
@@ -1308,6 +1308,25 @@ static enum rewrite_result rewrite_one(struct rev_info *revs, struct commit **pp
 	}
 }
 
+static void remove_duplicate_parents(struct commit *commit)
+{
+	struct commit_list *p;
+	struct commit_list **pp = &commit->parents;
+
+	/* Examine existing parents while marking ones we have seen... */
+	for (p = commit->parents; p; p = p->next) {
+		struct commit *parent = p->item;
+		if (parent->object.flags & TMP_MARK)
+			continue;
+		parent->object.flags |= TMP_MARK;
+		*pp = p;
+		pp = &p->next;
+	}
+	/* ... and clear the temporary mark */
+	for (p = commit->parents; p; p = p->next)
+		p->item->object.flags &= ~TMP_MARK;
+}
+
 static int rewrite_parents(struct rev_info *revs, struct commit *commit)
 {
 	struct commit_list **pp = &commit->parents;
@@ -1324,6 +1343,8 @@ static int rewrite_parents(struct rev_info *revs, struct commit *commit)
 		}
 		pp = &parent->next;
 	}
+	if (revs->simplify_history)
+		remove_duplicate_parents(commit);
 	return 0;
 }
 

  reply	other threads:[~2007-07-09  1:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-08 14:37 [PATCH] Fix "git log --parent -m" from emitting duplicated parent info Marco Costalba
2007-07-08 18:32 ` Junio C Hamano
2007-07-09  0:37 ` Junio C Hamano
2007-07-09  1:15   ` Johannes Schindelin
2007-07-09  1:28     ` Junio C Hamano
2007-07-09  1:20   ` Junio C Hamano
2007-07-09  1:22   ` Johannes Schindelin
2007-07-09  1:38     ` Junio C Hamano [this message]
2007-07-09  5:46       ` Marco Costalba
2007-07-09  6:19         ` 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=7vps32xsof.fsf@assigned-by-dhcp.cox.net \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=mcostalba@gmail.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).