3 test_description='git rev-list trivial path optimization test
7 o------------------------*----o main
9 o---------o----o----o----o side
16 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
17 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
21 test_expect_success setup '
28 git commit -m "Initial commit" &&
29 git rev-parse --verify HEAD &&
33 test_expect_success path-optimization '
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 &&
43 echo Irrelevant >d/f &&
46 git commit -m "Side makes an irrelevant commit" &&
48 echo "More Irrelevancy" >c &&
51 git commit -m "Side makes another irrelevant commit" &&
55 git commit -m "Side touches a" &&
57 echo "Yet more Irrelevancy" >c &&
60 git commit -m "Side makes yet another irrelevant commit" &&
66 git commit -m "Main touches b" &&
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