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>
This commit is contained in:

committed by
Junio C Hamano

parent
4d826608e9
commit
bf3418b08b
22
revision.c
22
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))
|
if (revs->min_age != -1 && (commit->date > revs->min_age))
|
||||||
return commit_ignore;
|
return commit_ignore;
|
||||||
if (revs->min_parents || (revs->max_parents >= 0)) {
|
if (revs->min_parents || (revs->max_parents >= 0)) {
|
||||||
int n = 0;
|
int n = commit_list_count(commit->parents);
|
||||||
struct commit_list *p;
|
|
||||||
for (p = commit->parents; p; p = p->next)
|
|
||||||
n++;
|
|
||||||
if ((n < revs->min_parents) ||
|
if ((n < revs->min_parents) ||
|
||||||
((revs->max_parents >= 0) && (n > revs->max_parents)))
|
((revs->max_parents >= 0) && (n > revs->max_parents)))
|
||||||
return commit_ignore;
|
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) {
|
if (revs->prune && revs->dense) {
|
||||||
/* Commit without changes? */
|
/* Commit without changes? */
|
||||||
if (commit->object.flags & TREESAME) {
|
if (commit->object.flags & TREESAME) {
|
||||||
|
int n;
|
||||||
|
struct commit_list *p;
|
||||||
/* drop merges unless we want parenthood */
|
/* drop merges unless we want parenthood */
|
||||||
if (!want_ancestry(revs))
|
if (!want_ancestry(revs))
|
||||||
return commit_ignore;
|
return commit_ignore;
|
||||||
/* non-merge - always ignore it */
|
/*
|
||||||
if (!commit->parents || !commit->parents->next)
|
* If we want ancestry, then need to keep any merges
|
||||||
return commit_ignore;
|
* 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;
|
return commit_show;
|
||||||
|
@ -139,7 +139,7 @@ check_result 'M L G' F..M --first-parent -- file
|
|||||||
# If we want history since E, then we're quite happy to ignore G that took E.
|
# If we want history since E, then we're quite happy to ignore G that took E.
|
||||||
check_result 'M L K J I H G' E..M --ancestry-path
|
check_result 'M L K J I H G' E..M --ancestry-path
|
||||||
check_result 'M L J I H' E..M --ancestry-path -- file
|
check_result 'M L J I H' E..M --ancestry-path -- file
|
||||||
check_outcome failure '(LH)M (K)L (EJ)K (I)J (E)I (E)H' E..M --ancestry-path --parents -- file # includes G
|
check_result '(LH)M (K)L (EJ)K (I)J (E)I (E)H' E..M --ancestry-path --parents -- file
|
||||||
check_result '(LH)M (E)H (J)L (I)J (E)I' E..M --ancestry-path --simplify-merges -- file
|
check_result '(LH)M (E)H (J)L (I)J (E)I' E..M --ancestry-path --simplify-merges -- file
|
||||||
|
|
||||||
# Should still be able to ignore I-J branch in simple log, despite limiting
|
# Should still be able to ignore I-J branch in simple log, despite limiting
|
||||||
@ -168,7 +168,7 @@ check_result '(D)F (BA)D' B..F --full-history --parents -- file
|
|||||||
check_result '(B)F' B..F --simplify-merges -- file
|
check_result '(B)F' B..F --simplify-merges -- file
|
||||||
check_result 'F D' B..F --ancestry-path
|
check_result 'F D' B..F --ancestry-path
|
||||||
check_result 'F' B..F --ancestry-path -- file
|
check_result 'F' B..F --ancestry-path -- file
|
||||||
check_outcome failure 'F' B..F --ancestry-path --parents -- file # includes D
|
check_result 'F' B..F --ancestry-path --parents -- file
|
||||||
check_result 'F' B..F --ancestry-path --simplify-merges -- file
|
check_result 'F' B..F --ancestry-path --simplify-merges -- file
|
||||||
check_result 'F D' B..F --first-parent
|
check_result 'F D' B..F --first-parent
|
||||||
check_result 'F' B..F --first-parent -- file
|
check_result 'F' B..F --first-parent -- file
|
||||||
|
Reference in New Issue
Block a user