]> git.ipfire.org Git - thirdparty/git.git/blame - t/t6019-rev-list-ancestry-path.sh
Merge branch 'ma/header-dup-cleanup'
[thirdparty/git.git] / t / t6019-rev-list-ancestry-path.sh
CommitLineData
ebdc94f3
JH
1#!/bin/sh
2
3test_description='--ancestry-path'
4
5# D---E-------F
6# / \ \
7# B---C---G---H---I---J
8# / \
9# A-------K---------------L--M
10#
11# D..M == E F G H I J K L M
12# --ancestry-path D..M == E F H I J L M
cb7529e1
JH
13#
14# D..M -- M.t == M
15# --ancestry-path D..M -- M.t == M
f659031c
KB
16#
17# F...I == F G H I
18# --ancestry-path F...I == F H I
c72424b1
KB
19#
20# G..M -- G.t == [nothing - was dropped in "-s ours" merge L]
4d826608
KB
21# --ancestry-path G..M -- G.t == L
22# --ancestry-path --simplify-merges G^..M -- G.t == G L
ebdc94f3 23
1550bb6e 24GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
334afbc7
JS
25export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
26
ebdc94f3
JH
27. ./test-lib.sh
28
29test_merge () {
30 test_tick &&
31 git merge -s ours -m "$2" "$1" &&
32 git tag "$2"
33}
34
35test_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
51'
52
53test_expect_success 'rev-list D..M' '
08495412 54 test_write_lines E F G H I J K L M >expect &&
ebdc94f3
JH
55 git rev-list --format=%s D..M |
56 sed -e "/^commit /d" |
57 sort >actual &&
58 test_cmp expect actual
59'
60
61test_expect_success 'rev-list --ancestry-path D..M' '
08495412 62 test_write_lines E F H I J L M >expect &&
ebdc94f3
JH
63 git rev-list --ancestry-path --format=%s D..M |
64 sed -e "/^commit /d" |
65 sort >actual &&
66 test_cmp expect actual
67'
68
cb7529e1
JH
69test_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
74'
75
f659031c 76test_expect_success 'rev-list --ancestry-path D..M -- M.t' '
cb7529e1
JH
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
81'
82
f659031c 83test_expect_success 'rev-list F...I' '
08495412 84 test_write_lines F G H I >expect &&
f659031c
KB
85 git rev-list --format=%s F...I |
86 sed -e "/^commit /d" |
87 sort >actual &&
88 test_cmp expect actual
89'
90
a765499a 91test_expect_success 'rev-list --ancestry-path F...I' '
08495412 92 test_write_lines F H I >expect &&
f659031c
KB
93 git rev-list --ancestry-path --format=%s F...I |
94 sed -e "/^commit /d" |
95 sort >actual &&
96 test_cmp expect actual
97'
98
c72424b1
KB
99# G.t is dropped in an "-s ours" merge
100test_expect_success 'rev-list G..M -- G.t' '
c72424b1
KB
101 git rev-list --format=%s G..M -- G.t |
102 sed -e "/^commit /d" >actual &&
d3c6751b 103 test_must_be_empty actual
c72424b1
KB
104'
105
d0af663e 106test_expect_success 'rev-list --ancestry-path G..M -- G.t' '
4d826608 107 echo L >expect &&
c72424b1 108 git rev-list --ancestry-path --format=%s G..M -- G.t |
4d826608
KB
109 sed -e "/^commit /d" >actual &&
110 test_cmp expect actual
111'
112
113test_expect_success 'rev-list --ancestry-path --simplify-merges G^..M -- G.t' '
08495412 114 test_write_lines G L >expect &&
4d826608 115 git rev-list --ancestry-path --simplify-merges --format=%s G^..M -- G.t |
c72424b1
KB
116 sed -e "/^commit /d" |
117 sort >actual &&
118 test_cmp expect actual
119'
120
81f49531
BK
121# b---bc
122# / \ /
123# a X
124# \ / \
125# c---cb
c05b988a
TR
126#
127# All refnames prefixed with 'x' to avoid confusion with the tags
128# generated by test_commit on case-insensitive systems.
81f49531
BK
129test_expect_success 'setup criss-cross' '
130 mkdir criss-cross &&
131 (cd criss-cross &&
132 git init &&
133 test_commit A &&
1550bb6e 134 git checkout -b xb main &&
81f49531 135 test_commit B &&
1550bb6e 136 git checkout -b xc main &&
81f49531 137 test_commit C &&
c05b988a
TR
138 git checkout -b xbc xb -- &&
139 git merge xc &&
140 git checkout -b xcb xc -- &&
141 git merge xb &&
1550bb6e 142 git checkout main)
81f49531
BK
143'
144
145# no commits in bc descend from cb
146test_expect_success 'criss-cross: rev-list --ancestry-path cb..bc' '
147 (cd criss-cross &&
c05b988a 148 git rev-list --ancestry-path xcb..xbc > actual &&
213dabf4 149 test_must_be_empty actual)
81f49531
BK
150'
151
152# no commits in repository descend from cb
c3502fa8 153test_expect_success 'criss-cross: rev-list --ancestry-path --all ^cb' '
81f49531 154 (cd criss-cross &&
c05b988a 155 git rev-list --ancestry-path --all ^xcb > actual &&
213dabf4 156 test_must_be_empty actual)
81f49531
BK
157'
158
ebdc94f3 159test_done