Merge branch 'mh/maint-lockfile-overflow' into maint
[git] / t / t6019-rev-list-ancestry-path.sh
1 #!/bin/sh
2
3 test_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
13 #
14 #  D..M -- M.t                 == M
15 #  --ancestry-path D..M -- M.t == M
16 #
17 #  F...I                 == F G H I
18 #  --ancestry-path F...I == F H I
19
20 . ./test-lib.sh
21
22 test_merge () {
23         test_tick &&
24         git merge -s ours -m "$2" "$1" &&
25         git tag "$2"
26 }
27
28 test_expect_success setup '
29         test_commit A &&
30         test_commit B &&
31         test_commit C &&
32         test_commit D &&
33         test_commit E &&
34         test_commit F &&
35         git reset --hard C &&
36         test_commit G &&
37         test_merge E H &&
38         test_commit I &&
39         test_merge F J &&
40         git reset --hard A &&
41         test_commit K &&
42         test_merge J L &&
43         test_commit M
44 '
45
46 test_expect_success 'rev-list D..M' '
47         for c in E F G H I J K L M; do echo $c; done >expect &&
48         git rev-list --format=%s D..M |
49         sed -e "/^commit /d" |
50         sort >actual &&
51         test_cmp expect actual
52 '
53
54 test_expect_success 'rev-list --ancestry-path D..M' '
55         for c in E F H I J L M; do echo $c; done >expect &&
56         git rev-list --ancestry-path --format=%s D..M |
57         sed -e "/^commit /d" |
58         sort >actual &&
59         test_cmp expect actual
60 '
61
62 test_expect_success 'rev-list D..M -- M.t' '
63         echo M >expect &&
64         git rev-list --format=%s D..M -- M.t |
65         sed -e "/^commit /d" >actual &&
66         test_cmp expect actual
67 '
68
69 test_expect_success 'rev-list --ancestry-path D..M -- M.t' '
70         echo M >expect &&
71         git rev-list --ancestry-path --format=%s D..M -- M.t |
72         sed -e "/^commit /d" >actual &&
73         test_cmp expect actual
74 '
75
76 test_expect_success 'rev-list F...I' '
77         for c in F G H I; do echo $c; done >expect &&
78         git rev-list --format=%s F...I |
79         sed -e "/^commit /d" |
80         sort >actual &&
81         test_cmp expect actual
82 '
83
84 test_expect_success 'rev-list --ancestry-path F...I' '
85         for c in F H I; do echo $c; done >expect &&
86         git rev-list --ancestry-path --format=%s F...I |
87         sed -e "/^commit /d" |
88         sort >actual &&
89         test_cmp expect actual
90 '
91
92 #   b---bc
93 #  / \ /
94 # a   X
95 #  \ / \
96 #   c---cb
97 #
98 # All refnames prefixed with 'x' to avoid confusion with the tags
99 # generated by test_commit on case-insensitive systems.
100 test_expect_success 'setup criss-cross' '
101         mkdir criss-cross &&
102         (cd criss-cross &&
103          git init &&
104          test_commit A &&
105          git checkout -b xb master &&
106          test_commit B &&
107          git checkout -b xc master &&
108          test_commit C &&
109          git checkout -b xbc xb -- &&
110          git merge xc &&
111          git checkout -b xcb xc -- &&
112          git merge xb &&
113          git checkout master)
114 '
115
116 # no commits in bc descend from cb
117 test_expect_success 'criss-cross: rev-list --ancestry-path cb..bc' '
118         (cd criss-cross &&
119          git rev-list --ancestry-path xcb..xbc > actual &&
120          test -z "$(cat actual)")
121 '
122
123 # no commits in repository descend from cb
124 test_expect_success 'criss-cross: rev-list --ancestry-path --all ^cb' '
125         (cd criss-cross &&
126          git rev-list --ancestry-path --all ^xcb > actual &&
127          test -z "$(cat actual)")
128 '
129
130 test_done