Merge branch 'master' of github.com:vnwildman/git
[alt-git.git] / t / t6019-rev-list-ancestry-path.sh
blobaf57a04b7ffa01644768ee507714ad5f5d5b79c6
1 #!/bin/sh
3 test_description='--ancestry-path'
5 # D---E-------F
6 # / \ \
7 # B---C---G---H---I---J
8 # / \
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
14 # D..M -- M.t == M
15 # --ancestry-path D..M -- M.t == M
17 # F...I == F G H I
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
27 . ./test-lib.sh
29 test_merge () {
30 test_tick &&
31 git merge -s ours -m "$2" "$1" &&
32 git tag "$2"
35 test_expect_success setup '
36 test_commit A &&
37 test_commit B &&
38 test_commit C &&
39 test_commit D &&
40 test_commit E &&
41 test_commit F &&
42 git reset --hard C &&
43 test_commit G &&
44 test_merge E H &&
45 test_commit I &&
46 test_merge F J &&
47 git reset --hard A &&
48 test_commit K &&
49 test_merge J L &&
50 test_commit M
53 test_expect_success 'rev-list D..M' '
54 test_write_lines E F G H I J K L M >expect &&
55 git rev-list --format=%s D..M |
56 sed -e "/^commit /d" |
57 sort >actual &&
58 test_cmp expect actual
61 test_expect_success 'rev-list --ancestry-path D..M' '
62 test_write_lines E F H I J L M >expect &&
63 git rev-list --ancestry-path --format=%s D..M |
64 sed -e "/^commit /d" |
65 sort >actual &&
66 test_cmp expect actual
69 test_expect_success 'rev-list D..M -- M.t' '
70 echo M >expect &&
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' '
77 echo M >expect &&
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 test_write_lines F G H I >expect &&
85 git rev-list --format=%s F...I |
86 sed -e "/^commit /d" |
87 sort >actual &&
88 test_cmp expect actual
91 test_expect_success 'rev-list --ancestry-path F...I' '
92 test_write_lines F H I >expect &&
93 git rev-list --ancestry-path --format=%s F...I |
94 sed -e "/^commit /d" |
95 sort >actual &&
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' '
107 echo L >expect &&
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 test_write_lines G L >expect &&
115 git rev-list --ancestry-path --simplify-merges --format=%s G^..M -- G.t |
116 sed -e "/^commit /d" |
117 sort >actual &&
118 test_cmp expect actual
121 # b---bc
122 # / \ /
123 # a X
124 # \ / \
125 # c---cb
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' '
130 mkdir criss-cross &&
131 (cd criss-cross &&
132 git init &&
133 test_commit A &&
134 git checkout -b xb main &&
135 test_commit B &&
136 git checkout -b xc main &&
137 test_commit C &&
138 git checkout -b xbc xb -- &&
139 git merge xc &&
140 git checkout -b xcb xc -- &&
141 git merge xb &&
142 git checkout main)
145 # no commits in bc descend from cb
146 test_expect_success 'criss-cross: rev-list --ancestry-path cb..bc' '
147 (cd criss-cross &&
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' '
154 (cd criss-cross &&
155 git rev-list --ancestry-path --all ^xcb > actual &&
156 test_must_be_empty actual)
159 test_done