3 test_description='--ancestry-path'
7 # B---C---G---H---I---J
9 # A-------K---------------L--M
11 # D..M == E F G H I J K L M
12 # --ancestry-path D..M == E F H I J L M
15 # --ancestry-path D..M -- M.t == M
18 # --ancestry-path F...I == F H I
20 # G..M -- G.t == [nothing - was dropped in "-s ours" merge L]
21 # --ancestry-path G..M -- G.t == L
22 # --ancestry-path --simplify-merges G^..M -- G.t == G L
24 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
25 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
31 git merge -s ours -m "$2" "$1" &&
35 test_expect_success setup '
53 test_expect_success 'rev-list D..M' '
54 for c in E F G H I J K L M; do echo $c; done >expect &&
55 git rev-list --format=%s D..M |
56 sed -e "/^commit /d" |
58 test_cmp expect actual
61 test_expect_success 'rev-list --ancestry-path D..M' '
62 for c in E F H I J L M; do echo $c; done >expect &&
63 git rev-list --ancestry-path --format=%s D..M |
64 sed -e "/^commit /d" |
66 test_cmp expect actual
69 test_expect_success 'rev-list D..M -- M.t' '
71 git rev-list --format=%s D..M -- M.t |
72 sed -e "/^commit /d" >actual &&
73 test_cmp expect actual
76 test_expect_success 'rev-list --ancestry-path D..M -- M.t' '
78 git rev-list --ancestry-path --format=%s D..M -- M.t |
79 sed -e "/^commit /d" >actual &&
80 test_cmp expect actual
83 test_expect_success 'rev-list F...I' '
84 for c in F G H I; do echo $c; done >expect &&
85 git rev-list --format=%s F...I |
86 sed -e "/^commit /d" |
88 test_cmp expect actual
91 test_expect_success 'rev-list --ancestry-path F...I' '
92 for c in F H I; do echo $c; done >expect &&
93 git rev-list --ancestry-path --format=%s F...I |
94 sed -e "/^commit /d" |
96 test_cmp expect actual
99 # G.t is dropped in an "-s ours" merge
100 test_expect_success 'rev-list G..M -- G.t' '
101 git rev-list --format=%s G..M -- G.t |
102 sed -e "/^commit /d" >actual &&
103 test_must_be_empty actual
106 test_expect_success 'rev-list --ancestry-path G..M -- G.t' '
108 git rev-list --ancestry-path --format=%s G..M -- G.t |
109 sed -e "/^commit /d" >actual &&
110 test_cmp expect actual
113 test_expect_success 'rev-list --ancestry-path --simplify-merges G^..M -- G.t' '
114 for c in G L; do echo $c; done >expect &&
115 git rev-list --ancestry-path --simplify-merges --format=%s G^..M -- G.t |
116 sed -e "/^commit /d" |
118 test_cmp expect actual
127 # All refnames prefixed with 'x' to avoid confusion with the tags
128 # generated by test_commit on case-insensitive systems.
129 test_expect_success 'setup criss-cross' '
134 git checkout -b xb main &&
136 git checkout -b xc main &&
138 git checkout -b xbc xb -- &&
140 git checkout -b xcb xc -- &&
145 # no commits in bc descend from cb
146 test_expect_success 'criss-cross: rev-list --ancestry-path cb..bc' '
148 git rev-list --ancestry-path xcb..xbc > actual &&
149 test_must_be_empty actual)
152 # no commits in repository descend from cb
153 test_expect_success 'criss-cross: rev-list --ancestry-path --all ^cb' '
155 git rev-list --ancestry-path --all ^xcb > actual &&
156 test_must_be_empty actual)