Merge branch 'l10n-de-2.40' of github.com:ralfth/git
[alt-git.git] / t / t6004-rev-list-path-optim.sh
blobcd4f420e2a1e3919985a29d174055fab0f50c85f
1 #!/bin/sh
3 test_description='git rev-list trivial path optimization test
5 d/z1
6 b0 b1
7 o------------------------*----o main
8 / /
9 o---------o----o----o----o side
10 a0 c0 c1 a1 c2
11 d/f0 d/f1
12 d/z0
16 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
17 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
19 . ./test-lib.sh
21 test_expect_success setup '
22 echo Hello >a &&
23 mkdir d &&
24 echo World >d/f &&
25 echo World >d/z &&
26 git add a d &&
27 test_tick &&
28 git commit -m "Initial commit" &&
29 git rev-parse --verify HEAD &&
30 git tag initial
33 test_expect_success path-optimization '
34 test_tick &&
35 commit=$(echo "Unchanged tree" | git commit-tree "HEAD^{tree}" -p HEAD) &&
36 test $(git rev-list $commit | wc -l) = 2 &&
37 test $(git rev-list $commit -- . | wc -l) = 1
40 test_expect_success 'further setup' '
41 git checkout -b side &&
42 echo Irrelevant >c &&
43 echo Irrelevant >d/f &&
44 git add c d/f &&
45 test_tick &&
46 git commit -m "Side makes an irrelevant commit" &&
47 git tag side_c0 &&
48 echo "More Irrelevancy" >c &&
49 git add c &&
50 test_tick &&
51 git commit -m "Side makes another irrelevant commit" &&
52 echo Bye >a &&
53 git add a &&
54 test_tick &&
55 git commit -m "Side touches a" &&
56 git tag side_a1 &&
57 echo "Yet more Irrelevancy" >c &&
58 git add c &&
59 test_tick &&
60 git commit -m "Side makes yet another irrelevant commit" &&
61 git checkout main &&
62 echo Another >b &&
63 echo Munged >d/z &&
64 git add b d/z &&
65 test_tick &&
66 git commit -m "Main touches b" &&
67 git tag main_b0 &&
68 git merge side &&
69 echo Touched >b &&
70 git add b &&
71 test_tick &&
72 git commit -m "Main touches b again"
75 test_expect_success 'path optimization 2' '
76 git rev-parse side_a1 initial >expected &&
77 git rev-list HEAD -- a >actual &&
78 test_cmp expected actual
81 test_expect_success 'pathspec with leading path' '
82 git rev-parse main^ main_b0 side_c0 initial >expected &&
83 git rev-list HEAD -- d >actual &&
84 test_cmp expected actual
87 test_expect_success 'pathspec with glob (1)' '
88 git rev-parse main^ main_b0 side_c0 initial >expected &&
89 git rev-list HEAD -- "d/*" >actual &&
90 test_cmp expected actual
93 test_expect_success 'pathspec with glob (2)' '
94 git rev-parse side_c0 initial >expected &&
95 git rev-list HEAD -- "d/[a-m]*" >actual &&
96 test_cmp expected actual
99 test_done