git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Rast <trast@student.ethz.ch>
To: <git@vger.kernel.org>
Cc: "Junio C Hamano" <gitster@pobox.com>,
	"Björn Steinbrink" <B.Steinbrink@gmx.de>,
	"Adam Simpkins" <adam@adamsimpkins.net>
Subject: [RFC PATCH] Simplify away duplicate commits with --cherry-pick --parents
Date: Sat, 8 Aug 2009 18:34:26 +0200	[thread overview]
Message-ID: <50f4386635a3ab08ee7fd432d672f775cc760f39.1249749019.git.trast@student.ethz.ch> (raw)
In-Reply-To: <200908060919.27780.trast@student.ethz.ch>

The current --cherry-pick declares commits SHOWN that are found to be
duplicates.  Unfortunately this disconnects the history at every such
duplicate, making it quite hard to follow in graphical viewers.

Add an extra stage of parent rewriting after scanning for duplicates,
which simplifies the history to omit all duplicate commits.  This
cannot easily be shifted to the existing parent rewriting because
cherry_pick_list() always comes last in the entire filtering process
(presumably because it is the most expensive).

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---

I wrote:
> The problem with [gitk --left-right --cherry-pick A...B] is that it
> disconnects history
[...]
> Sadly, it's really the underlying git-rev-list that is "broken" in the
> sense that it does not fix the parent lists.  And git log --graph
> handles it much worse than gitk.

Maybe this is an approach.  It unfortunately breaks down if merges can
disappear because of patch-ids too.  Can they?

(In the case where a merge is flagged SHOWN, it might have its parent
list reduced to one at some point, and then later filterings would
simplify it away whereas earlier ones didn't.)

Also, I'm not entirely sure we want to do this without any guards
except rewrite_parents.

On the plus side, the issues with git log --graph vanish because
history is again connected :-)


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

diff --git a/revision.c b/revision.c
index 9f5dac5..9e24514 100644
--- a/revision.c
+++ b/revision.c
@@ -517,6 +517,8 @@ static int add_parents_to_list(struct rev_info *revs, struct commit *commit,
 	return 0;
 }
 
+static int remove_duplicate_parents(struct commit *commit);
+
 static void cherry_pick_list(struct commit_list *list, struct rev_info *revs)
 {
 	struct commit_list *p;
@@ -599,6 +601,25 @@ static void cherry_pick_list(struct commit_list *list, struct rev_info *revs)
 		commit->util = NULL;
 	}
 
+	if (revs->rewrite_parents) {
+		/* Prune away commits we've just found to be duplicates */
+		for (p = list; p; p = p->next) {
+			struct commit *commit = p->item;
+			struct commit_list *pp;
+
+			for (pp = commit->parents; pp; pp = pp->next) {
+				struct commit *parent = pp->item;
+				while (parent->object.flags & SHOWN
+				       && parent->parents
+				       && !parent->parents->next)
+					parent = parent->parents->item;
+				pp->item = parent;
+			}
+
+			remove_duplicate_parents(commit);
+		}
+	}
+
 	free_patch_ids(&ids);
 }
 
-- 
1.6.4.199.g24c3

      reply	other threads:[~2009-08-08 16:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-01 12:47 [GITK PATCH] gitk: fix direction of --left-right triangles Thomas Rast
2009-08-05 21:15 ` [PATCH v2] gitk: fix direction of symmetric difference in optimized mode Thomas Rast
     [not found]   ` <19066.8802.98042.957009@cargo.ozlabs.ibm.com>
2009-08-06  7:19     ` Thomas Rast
2009-08-08 16:34       ` Thomas Rast [this message]

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=50f4386635a3ab08ee7fd432d672f775cc760f39.1249749019.git.trast@student.ethz.ch \
    --to=trast@student.ethz.ch \
    --cc=B.Steinbrink@gmx.de \
    --cc=adam@adamsimpkins.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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).