summaryrefslogtreecommitdiff
path: root/revision.c
diff options
context:
space:
mode:
authorKevin Bracey <kevin@bracey.fi>2013-05-16 15:32:40 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-05-16 18:51:10 (GMT)
commitbf3418b08bac89902a5f6c70f8695f148df99828 (patch)
tree6b2f5d7fec00f019abf2afea302f419477fe4fa6 /revision.c
parent4d826608e9610851d29440ca290e54b701921608 (diff)
downloadgit-bf3418b08bac89902a5f6c70f8695f148df99828.zip
git-bf3418b08bac89902a5f6c70f8695f148df99828.tar.gz
git-bf3418b08bac89902a5f6c70f8695f148df99828.tar.bz2
revision.c: don't show all merges for --parents
When using --parents or --children, get_commit_action() previously showed all merges, even if TREESAME to both parents. This was intended to tie together the topology of the rewritten parents, but it was excessive - in fact we only need to show merges that have two or more relevant parents. Merges at the boundary do not necessarily need to be shown. Signed-off-by: Kevin Bracey <kevin@bracey.fi> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'revision.c')
-rw-r--r--revision.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/revision.c b/revision.c
index 1c75070..edb7e1c 100644
--- a/revision.c
+++ b/revision.c
@@ -2760,10 +2760,7 @@ enum commit_action get_commit_action(struct rev_info *revs, struct commit *commi
if (revs->min_age != -1 && (commit->date > revs->min_age))
return commit_ignore;
if (revs->min_parents || (revs->max_parents >= 0)) {
- int n = 0;
- struct commit_list *p;
- for (p = commit->parents; p; p = p->next)
- n++;
+ int n = commit_list_count(commit->parents);
if ((n < revs->min_parents) ||
((revs->max_parents >= 0) && (n > revs->max_parents)))
return commit_ignore;
@@ -2773,12 +2770,23 @@ enum commit_action get_commit_action(struct rev_info *revs, struct commit *commi
if (revs->prune && revs->dense) {
/* Commit without changes? */
if (commit->object.flags & TREESAME) {
+ int n;
+ struct commit_list *p;
/* drop merges unless we want parenthood */
if (!want_ancestry(revs))
return commit_ignore;
- /* non-merge - always ignore it */
- if (!commit->parents || !commit->parents->next)
- return commit_ignore;
+ /*
+ * If we want ancestry, then need to keep any merges
+ * between relevant commits to tie together topology.
+ * For consistency with TREESAME and simplification
+ * use "relevant" here rather than just INTERESTING,
+ * to treat bottom commit(s) as part of the topology.
+ */
+ for (n = 0, p = commit->parents; p; p = p->next)
+ if (relevant_commit(p->item))
+ if (++n >= 2)
+ return commit_show;
+ return commit_ignore;
}
}
return commit_show;