Skip to content

Commit c3502fa

Browse files
committed
revision: do not include sibling history in --ancestry-path output
If the commit specified as the bottom of the commit range has a direct parent that has another child commit that contributed to the resulting history, "rev-list --ancestry-path" was confused and listed that side history as well, due to the command line parser subtlety corrected by the previous commit. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 281eee4 commit c3502fa

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

revision.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -724,12 +724,16 @@ static void limit_to_ancestry(struct commit_list *bottom, struct commit_list *li
724724
* to filter the result of "A..B" further to the ones that can actually
725725
* reach A.
726726
*/
727-
static struct commit_list *collect_bottom_commits(struct commit_list *list)
727+
static struct commit_list *collect_bottom_commits(struct rev_info *revs)
728728
{
729-
struct commit_list *elem, *bottom = NULL;
730-
for (elem = list; elem; elem = elem->next)
731-
if (elem->item->object.flags & UNINTERESTING)
732-
commit_list_insert(elem->item, &bottom);
729+
struct commit_list *bottom = NULL;
730+
int i;
731+
for (i = 0; i < revs->cmdline.nr; i++) {
732+
struct rev_cmdline_entry *elem = &revs->cmdline.rev[i];
733+
if ((elem->flags & UNINTERESTING) &&
734+
elem->item->type == OBJ_COMMIT)
735+
commit_list_insert((struct commit *)elem->item, &bottom);
736+
}
733737
return bottom;
734738
}
735739

@@ -743,7 +747,7 @@ static int limit_list(struct rev_info *revs)
743747
struct commit_list *bottom = NULL;
744748

745749
if (revs->ancestry_path) {
746-
bottom = collect_bottom_commits(list);
750+
bottom = collect_bottom_commits(revs);
747751
if (!bottom)
748752
die("--ancestry-path given but there are no bottom commits");
749753
}

t/t6019-rev-list-ancestry-path.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ test_expect_success 'criss-cross: rev-list --ancestry-path cb..bc' '
9999
'
100100

101101
# no commits in repository descend from cb
102-
test_expect_failure 'criss-cross: rev-list --ancestry-path --all ^cb' '
102+
test_expect_success 'criss-cross: rev-list --ancestry-path --all ^cb' '
103103
(cd criss-cross &&
104104
git rev-list --ancestry-path --all ^cb > actual &&
105105
test -z "$(cat actual)")

0 commit comments

Comments
 (0)