3 test_description='git rev-list trivial path optimization test
7 o------------------------*----o master
9 o---------o----o----o----o side
18 test_expect_success setup '
25 git commit -m "Initial commit" &&
26 git rev-parse --verify HEAD &&
30 test_expect_success path-optimization '
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
37 test_expect_success 'further setup' '
38 git checkout -b side &&
40 echo Irrelevant >d/f &&
43 git commit -m "Side makes an irrelevant commit" &&
45 echo "More Irrelevancy" >c &&
48 git commit -m "Side makes another irrelevant commit" &&
52 git commit -m "Side touches a" &&
54 echo "Yet more Irrelevancy" >c &&
57 git commit -m "Side makes yet another irrelevant commit" &&
58 git checkout master &&
63 git commit -m "Master touches b" &&
69 git commit -m "Master touches b again"
72 test_expect_success 'path optimization 2' '
73 git rev-parse side_a1 initial >expected &&
74 git rev-list HEAD -- a >actual &&
75 test_cmp expected actual
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
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
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