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 <gitster@pobox.com>
Junio C Hamano committed
Aug 25, 2011 at 17:51 UTC
c3502fa8822fab99ee51b3f74cf3f100492d88e2
2 files changed
+11
-7
revision.c
+10
-6
@@ -724,12 +724,16 @@ static void limit_to_ancestry(struct commit_list *bottom, struct commit_list *li
724
* to filter the result of "A..B" further to the ones that can actually
725
* reach A.
726
*/
727
-static struct commit_list *collect_bottom_commits(struct commit_list *list)
727
+static struct commit_list *collect_bottom_commits(struct rev_info *revs)
728
{
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
+ }
737
return bottom;
738
}
739
@@ -743,7 +747,7 @@ static int limit_list(struct rev_info *revs)
747
struct commit_list *bottom = NULL;
748
749
if (revs->ancestry_path) {
746
- bottom = collect_bottom_commits(list);
750
+ bottom = collect_bottom_commits(revs);
751
if (!bottom)
752
die("--ancestry-path given but there are no bottom commits");
753
}
t/t6019-rev-list-ancestry-path.sh
+1
-1
@@ -99,7 +99,7 @@ test_expect_success 'criss-cross: rev-list --ancestry-path cb..bc' '
99
'
100
101
# 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' '
103
(cd criss-cross &&
104
git rev-list --ancestry-path --all ^cb > actual &&
105
test -z "$(cat actual)")