]> git.ipfire.org Git - thirdparty/git.git/blame - t/t6004-rev-list-path-optim.sh
The third batch
[thirdparty/git.git] / t / t6004-rev-list-path-optim.sh
CommitLineData
57c7d9a7
AR
1#!/bin/sh
2
f577b92f
JH
3test_description='git rev-list trivial path optimization test
4
5 d/z1
6 b0 b1
1550bb6e 7 o------------------------*----o main
f577b92f
JH
8 / /
9 o---------o----o----o----o side
10 a0 c0 c1 a1 c2
11 d/f0 d/f1
12 d/z0
13
14'
57c7d9a7 15
1550bb6e 16GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
334afbc7
JS
17export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
18
57c7d9a7
AR
19. ./test-lib.sh
20
21test_expect_success setup '
f577b92f
JH
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
57c7d9a7
AR
31'
32
33test_expect_success path-optimization '
f577b92f
JH
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
57c7d9a7
AR
38'
39
bab36bf5
JH
40test_expect_success 'further setup' '
41 git checkout -b side &&
42 echo Irrelevant >c &&
f577b92f
JH
43 echo Irrelevant >d/f &&
44 git add c d/f &&
45 test_tick &&
bab36bf5 46 git commit -m "Side makes an irrelevant commit" &&
f577b92f 47 git tag side_c0 &&
bab36bf5
JH
48 echo "More Irrelevancy" >c &&
49 git add c &&
f577b92f 50 test_tick &&
bab36bf5
JH
51 git commit -m "Side makes another irrelevant commit" &&
52 echo Bye >a &&
53 git add a &&
f577b92f 54 test_tick &&
bab36bf5 55 git commit -m "Side touches a" &&
f577b92f 56 git tag side_a1 &&
bab36bf5
JH
57 echo "Yet more Irrelevancy" >c &&
58 git add c &&
f577b92f 59 test_tick &&
bab36bf5 60 git commit -m "Side makes yet another irrelevant commit" &&
1550bb6e 61 git checkout main &&
bab36bf5 62 echo Another >b &&
f577b92f
JH
63 echo Munged >d/z &&
64 git add b d/z &&
65 test_tick &&
1550bb6e
JS
66 git commit -m "Main touches b" &&
67 git tag main_b0 &&
bab36bf5
JH
68 git merge side &&
69 echo Touched >b &&
70 git add b &&
f577b92f 71 test_tick &&
1550bb6e 72 git commit -m "Main touches b again"
bab36bf5
JH
73'
74
75test_expect_success 'path optimization 2' '
f577b92f 76 git rev-parse side_a1 initial >expected &&
bab36bf5 77 git rev-list HEAD -- a >actual &&
82ebb0b6 78 test_cmp expected actual
bab36bf5
JH
79'
80
f577b92f 81test_expect_success 'pathspec with leading path' '
1550bb6e 82 git rev-parse main^ main_b0 side_c0 initial >expected &&
f577b92f
JH
83 git rev-list HEAD -- d >actual &&
84 test_cmp expected actual
85'
86
87test_expect_success 'pathspec with glob (1)' '
1550bb6e 88 git rev-parse main^ main_b0 side_c0 initial >expected &&
f577b92f
JH
89 git rev-list HEAD -- "d/*" >actual &&
90 test_cmp expected actual
91'
92
93test_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
97'
98
57c7d9a7 99test_done