]>
Commit | Line | Data |
---|---|---|
57c7d9a7 AR |
1 | #!/bin/sh |
2 | ||
f577b92f JH |
3 | test_description='git rev-list trivial path optimization test |
4 | ||
5 | d/z1 | |
6 | b0 b1 | |
7 | o------------------------*----o master | |
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 AR |
15 | |
16 | . ./test-lib.sh | |
17 | ||
18 | test_expect_success setup ' | |
f577b92f JH |
19 | echo Hello >a && |
20 | mkdir d && | |
21 | echo World >d/f && | |
22 | echo World >d/z && | |
23 | git add a d && | |
24 | test_tick && | |
25 | git commit -m "Initial commit" && | |
26 | git rev-parse --verify HEAD && | |
27 | git tag initial | |
57c7d9a7 AR |
28 | ' |
29 | ||
30 | test_expect_success path-optimization ' | |
f577b92f JH |
31 | test_tick && |
32 | commit=$(echo "Unchanged tree" | git commit-tree "HEAD^{tree}" -p HEAD) && | |
33 | test $(git rev-list $commit | wc -l) = 2 && | |
34 | test $(git rev-list $commit -- . | wc -l) = 1 | |
57c7d9a7 AR |
35 | ' |
36 | ||
bab36bf5 JH |
37 | test_expect_success 'further setup' ' |
38 | git checkout -b side && | |
39 | echo Irrelevant >c && | |
f577b92f JH |
40 | echo Irrelevant >d/f && |
41 | git add c d/f && | |
42 | test_tick && | |
bab36bf5 | 43 | git commit -m "Side makes an irrelevant commit" && |
f577b92f | 44 | git tag side_c0 && |
bab36bf5 JH |
45 | echo "More Irrelevancy" >c && |
46 | git add c && | |
f577b92f | 47 | test_tick && |
bab36bf5 JH |
48 | git commit -m "Side makes another irrelevant commit" && |
49 | echo Bye >a && | |
50 | git add a && | |
f577b92f | 51 | test_tick && |
bab36bf5 | 52 | git commit -m "Side touches a" && |
f577b92f | 53 | git tag side_a1 && |
bab36bf5 JH |
54 | echo "Yet more Irrelevancy" >c && |
55 | git add c && | |
f577b92f | 56 | test_tick && |
bab36bf5 JH |
57 | git commit -m "Side makes yet another irrelevant commit" && |
58 | git checkout master && | |
59 | echo Another >b && | |
f577b92f JH |
60 | echo Munged >d/z && |
61 | git add b d/z && | |
62 | test_tick && | |
bab36bf5 | 63 | git commit -m "Master touches b" && |
f577b92f | 64 | git tag master_b0 && |
bab36bf5 JH |
65 | git merge side && |
66 | echo Touched >b && | |
67 | git add b && | |
f577b92f | 68 | test_tick && |
bab36bf5 JH |
69 | git commit -m "Master touches b again" |
70 | ' | |
71 | ||
72 | test_expect_success 'path optimization 2' ' | |
f577b92f | 73 | git rev-parse side_a1 initial >expected && |
bab36bf5 | 74 | git rev-list HEAD -- a >actual && |
82ebb0b6 | 75 | test_cmp expected actual |
bab36bf5 JH |
76 | ' |
77 | ||
f577b92f JH |
78 | test_expect_success 'pathspec with leading path' ' |
79 | git rev-parse master^ master_b0 side_c0 initial >expected && | |
80 | git rev-list HEAD -- d >actual && | |
81 | test_cmp expected actual | |
82 | ' | |
83 | ||
84 | test_expect_success 'pathspec with glob (1)' ' | |
85 | git rev-parse master^ master_b0 side_c0 initial >expected && | |
86 | git rev-list HEAD -- "d/*" >actual && | |
87 | test_cmp expected actual | |
88 | ' | |
89 | ||
90 | test_expect_success 'pathspec with glob (2)' ' | |
91 | git rev-parse side_c0 initial >expected && | |
92 | git rev-list HEAD -- "d/[a-m]*" >actual && | |
93 | test_cmp expected actual | |
94 | ' | |
95 | ||
57c7d9a7 | 96 | test_done |