Merge branch 'ds/in-merge-bases-many-optim-bug'
in_merge_bases_many(), a way to see if a commit is reachable from any commit in a set of commits, was totally broken when the commit-graph feature was in use, which has been corrected. * ds/in-merge-bases-many-optim-bug: commit-reach: fix in_merge_bases_many bug
This commit is contained in:
commit
c01b041ef0
@ -321,7 +321,7 @@ int repo_in_merge_bases_many(struct repository *r, struct commit *commit,
|
||||
{
|
||||
struct commit_list *bases;
|
||||
int ret = 0, i;
|
||||
uint32_t generation, min_generation = GENERATION_NUMBER_INFINITY;
|
||||
uint32_t generation, max_generation = GENERATION_NUMBER_ZERO;
|
||||
|
||||
if (repo_parse_commit(r, commit))
|
||||
return ret;
|
||||
@ -330,12 +330,12 @@ int repo_in_merge_bases_many(struct repository *r, struct commit *commit,
|
||||
return ret;
|
||||
|
||||
generation = commit_graph_generation(reference[i]);
|
||||
if (generation < min_generation)
|
||||
min_generation = generation;
|
||||
if (generation > max_generation)
|
||||
max_generation = generation;
|
||||
}
|
||||
|
||||
generation = commit_graph_generation(commit);
|
||||
if (generation > min_generation)
|
||||
if (generation > max_generation)
|
||||
return ret;
|
||||
|
||||
bases = paint_down_to_common(r, commit,
|
||||
|
@ -107,6 +107,8 @@ int cmd__reach(int ac, const char **av)
|
||||
printf("%s(A,B):%d\n", av[1], ref_newer(&oid_A, &oid_B));
|
||||
else if (!strcmp(av[1], "in_merge_bases"))
|
||||
printf("%s(A,B):%d\n", av[1], in_merge_bases(A, B));
|
||||
else if (!strcmp(av[1], "in_merge_bases_many"))
|
||||
printf("%s(A,X):%d\n", av[1], in_merge_bases_many(A, X_nr, X_array));
|
||||
else if (!strcmp(av[1], "is_descendant_of"))
|
||||
printf("%s(A,X):%d\n", av[1], repo_is_descendant_of(r, A, X));
|
||||
else if (!strcmp(av[1], "get_merge_bases_many")) {
|
||||
|
@ -110,6 +110,36 @@ test_expect_success 'in_merge_bases:miss' '
|
||||
test_three_modes in_merge_bases
|
||||
'
|
||||
|
||||
test_expect_success 'in_merge_bases_many:hit' '
|
||||
cat >input <<-\EOF &&
|
||||
A:commit-6-8
|
||||
X:commit-6-9
|
||||
X:commit-5-7
|
||||
EOF
|
||||
echo "in_merge_bases_many(A,X):1" >expect &&
|
||||
test_three_modes in_merge_bases_many
|
||||
'
|
||||
|
||||
test_expect_success 'in_merge_bases_many:miss' '
|
||||
cat >input <<-\EOF &&
|
||||
A:commit-6-8
|
||||
X:commit-7-7
|
||||
X:commit-8-6
|
||||
EOF
|
||||
echo "in_merge_bases_many(A,X):0" >expect &&
|
||||
test_three_modes in_merge_bases_many
|
||||
'
|
||||
|
||||
test_expect_success 'in_merge_bases_many:miss-heuristic' '
|
||||
cat >input <<-\EOF &&
|
||||
A:commit-6-8
|
||||
X:commit-7-5
|
||||
X:commit-6-6
|
||||
EOF
|
||||
echo "in_merge_bases_many(A,X):0" >expect &&
|
||||
test_three_modes in_merge_bases_many
|
||||
'
|
||||
|
||||
test_expect_success 'is_descendant_of:hit' '
|
||||
cat >input <<-\EOF &&
|
||||
A:commit-5-7
|
||||
|
Loading…
Reference in New Issue
Block a user