Skip to content

Commit 911439a

Browse files
committed
Merge branch 'kb/ancestry-path-threedots'
"git log --ancestry-path A...B" did not work as expected, as it did not pay attention to the fact that the merge base between A and B was the bottom of the range being specified. * kb/ancestry-path-threedots: revision.c: treat A...B merge bases as if manually specified t6019: demonstrate --ancestry-path A...B breakage
2 parents aaec1ad + a765499 commit 911439a

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

revision.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,19 @@ static void add_rev_cmdline(struct rev_info *revs,
915915
info->nr++;
916916
}
917917

918+
static void add_rev_cmdline_list(struct rev_info *revs,
919+
struct commit_list *commit_list,
920+
int whence,
921+
unsigned flags)
922+
{
923+
while (commit_list) {
924+
struct object *object = &commit_list->item->object;
925+
add_rev_cmdline(revs, object, sha1_to_hex(object->sha1),
926+
whence, flags);
927+
commit_list = commit_list->next;
928+
}
929+
}
930+
918931
struct all_refs_cb {
919932
int all_flags;
920933
int warned_bad_reflog;
@@ -1092,6 +1105,7 @@ static void prepare_show_merge(struct rev_info *revs)
10921105
add_pending_object(revs, &head->object, "HEAD");
10931106
add_pending_object(revs, &other->object, "MERGE_HEAD");
10941107
bases = get_merge_bases(head, other, 1);
1108+
add_rev_cmdline_list(revs, bases, REV_CMD_MERGE_BASE, UNINTERESTING);
10951109
add_pending_commit_list(revs, bases, UNINTERESTING);
10961110
free_commit_list(bases);
10971111
head->object.flags |= SYMMETRIC_LEFT;
@@ -1179,6 +1193,9 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi
11791193

11801194
if (symmetric) {
11811195
exclude = get_merge_bases(a, b, 1);
1196+
add_rev_cmdline_list(revs, exclude,
1197+
REV_CMD_MERGE_BASE,
1198+
flags_exclude);
11821199
add_pending_commit_list(revs, exclude,
11831200
flags_exclude);
11841201
free_commit_list(exclude);

revision.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ struct rev_cmdline_info {
3535
REV_CMD_PARENTS_ONLY,
3636
REV_CMD_LEFT,
3737
REV_CMD_RIGHT,
38+
REV_CMD_MERGE_BASE,
3839
REV_CMD_REV
3940
} whence;
4041
unsigned flags;

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ test_description='--ancestry-path'
1313
#
1414
# D..M -- M.t == M
1515
# --ancestry-path D..M -- M.t == M
16+
#
17+
# F...I == F G H I
18+
# --ancestry-path F...I == F H I
1619

1720
. ./test-lib.sh
1821

@@ -63,13 +66,29 @@ test_expect_success 'rev-list D..M -- M.t' '
6366
test_cmp expect actual
6467
'
6568

66-
test_expect_success 'rev-list --ancestry-patch D..M -- M.t' '
69+
test_expect_success 'rev-list --ancestry-path D..M -- M.t' '
6770
echo M >expect &&
6871
git rev-list --ancestry-path --format=%s D..M -- M.t |
6972
sed -e "/^commit /d" >actual &&
7073
test_cmp expect actual
7174
'
7275

76+
test_expect_success 'rev-list F...I' '
77+
for c in F G H I; do echo $c; done >expect &&
78+
git rev-list --format=%s F...I |
79+
sed -e "/^commit /d" |
80+
sort >actual &&
81+
test_cmp expect actual
82+
'
83+
84+
test_expect_success 'rev-list --ancestry-path F...I' '
85+
for c in F H I; do echo $c; done >expect &&
86+
git rev-list --ancestry-path --format=%s F...I |
87+
sed -e "/^commit /d" |
88+
sort >actual &&
89+
test_cmp expect actual
90+
'
91+
7392
# b---bc
7493
# / \ /
7594
# a X

0 commit comments

Comments
 (0)