interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / t / t6099-merge-base-side-exhaustion.sh

82 lines · 1881 bytes Raw Blame History
1#!/bin/sh
2
3test_description='merge-base with ancestor among merge-base candidates
4
5Test that merge-base --all correctly handles cases where
6multiple merge-base candidates exist and one is an ancestor
7of another. The side-exhaustion optimization in
8paint_down_to_common may exit before STALE propagation
9removes the ancestor, but remove_redundant catches it.
10
11Graph shape (parents are below children):
12
13 A ----- X
14 |\ /|
15 | B---/ |
16 | \ |
17 e2 \ f2
18 | | |
19 e1 d1 f1
20 \ | /
21 \ | /
22 \|/
23 C
24
25A and X are the two tips.
26B and C are both reachable from A and X.
27B reaches C through d1.
28Only B should appear in merge-base --all output.
29'
30
31GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
32export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
33
34TEST_PASSES_SANITIZE_LEAK=true
35. ./test-lib.sh
36
37test_expect_success 'setup ancestor merge-base candidate' '
38 test_commit C &&
39
40 git checkout -b d-chain HEAD &&
41 test_commit d1 &&
42 test_commit B &&
43
44 git checkout -b e-path C &&
45 test_commit e1 &&
46 test_commit e2 &&
47
48 git checkout -b f-path C &&
49 test_commit f1 &&
50 test_commit f2 &&
51
52 git checkout -b branch-A e-path &&
53 test_merge A B &&
54
55 git checkout -b branch-X f-path &&
56 test_merge X B &&
57
58 git commit-graph write --reachable
59'
60
61test_expect_success 'merge-base --all excludes ancestor candidate' '
62 git rev-parse B >expected &&
63 git merge-base --all A X >actual &&
64 test_cmp expected actual
65'
66
67test_expect_success 'merge-base (single) finds shallowest' '
68 git rev-parse B >expected &&
69 git merge-base A X >actual &&
70 test_cmp expected actual
71'
72
73# Without commit-graph: generation numbers are INFINITY,
74# side-exhaustion optimization does not fire.
75test_expect_success 'merge-base --all without commit-graph' '
76 rm -f .git/objects/info/commit-graph &&
77 git rev-parse B >expected &&
78 git merge-base --all A X >actual &&
79 test_cmp expected actual
80'
81
82test_done