[PATCH 2/2] revision: do not include sibling history in --ancestry-path output
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 26, 2011, 01:00 UTC
- Message-ID
- <7v7h61gf5i.fsf_-_@alter.siamese.dyndns.org>
- In-Reply-To
- <438ea0b254ccafb3fc9f3431f8f86007cc03132b.1314290439.git.brad.king@kitware.com>
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.
D---E
/ \
---X---A---B---CIn this history, "rev-list --ancestry-path A..C" should list among what the corresponding command without --ancestry-path option would produce, namely, D, E, B and C, but limiting the result to those that are descendant of A (i.e. B and C). Due to the command line parser subtlety corrected by the previous commit, it also listed those that are descendant of X as well.
Signed-off-by: Junio C Hamano <gitster@pobox.com> --- * And this should fix the breakage you demonstrated.
revision.c | 16 ++++++++++------ 1 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/revision.c b/revision.c index 3e87c86..48a2db4 100644 --- a/revision.c +++ b/revision.c @@ -724,12 +724,16 @@ static void limit_to_ancestry(struct commit_list *bottom, struct commit_list *li * to filter the result of "A..B" further to the ones that can actually * reach A. */ -static struct commit_list *collect_bottom_commits(struct commit_list *list) +static struct commit_list *collect_bottom_commits(struct rev_info *revs) { - struct commit_list *elem, *bottom = NULL; - for (elem = list; elem; elem = elem->next) - if (elem->item->object.flags & UNINTERESTING) - commit_list_insert(elem->item, &bottom); + struct commit_list *bottom = NULL; + int i; + for (i = 0; i < revs->cmdline.nr; i++) { + struct rev_cmdline_entry *elem = &revs->cmdline.rev[i]; + if ((elem->flags & UNINTERESTING) && + elem->item->type == OBJ_COMMIT) + commit_list_insert((struct commit *)elem->item, &bottom); + } return bottom; } @@ -743,7 +747,7 @@ static int limit_list(struct rev_info *revs) struct commit_list *bottom = NULL; if (revs->ancestry_path) { - bottom = collect_bottom_commits(list); + bottom = collect_bottom_commits(revs); if (!bottom) die("--ancestry-path given but there are no bottom commits"); }
-- 1.7.6.1.385.gb7fcd0