]>
Commit | Line | Data |
---|---|---|
ebdc94f3 JH |
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 | |
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 JH |
23 | |
24 | . ./test-lib.sh | |
25 | ||
26 | test_merge () { | |
27 | test_tick && | |
28 | git merge -s ours -m "$2" "$1" && | |
29 | git tag "$2" | |
30 | } | |
31 | ||
32 | test_expect_success setup ' | |
33 | test_commit A && | |
34 | test_commit B && | |
35 | test_commit C && | |
36 | test_commit D && | |
37 | test_commit E && | |
38 | test_commit F && | |
39 | git reset --hard C && | |
40 | test_commit G && | |
41 | test_merge E H && | |
42 | test_commit I && | |
43 | test_merge F J && | |
44 | git reset --hard A && | |
45 | test_commit K && | |
46 | test_merge J L && | |
47 | test_commit M | |
48 | ' | |
49 | ||
50 | test_expect_success 'rev-list D..M' ' | |
51 | for c in E F G H I J K L M; do echo $c; done >expect && | |
52 | git rev-list --format=%s D..M | | |
53 | sed -e "/^commit /d" | | |
54 | sort >actual && | |
55 | test_cmp expect actual | |
56 | ' | |
57 | ||
58 | test_expect_success 'rev-list --ancestry-path D..M' ' | |
59 | for c in E F H I J L M; do echo $c; done >expect && | |
60 | git rev-list --ancestry-path --format=%s D..M | | |
61 | sed -e "/^commit /d" | | |
62 | sort >actual && | |
63 | test_cmp expect actual | |
64 | ' | |
65 | ||
cb7529e1 JH |
66 | test_expect_success 'rev-list D..M -- M.t' ' |
67 | echo M >expect && | |
68 | git rev-list --format=%s D..M -- M.t | | |
69 | sed -e "/^commit /d" >actual && | |
70 | test_cmp expect actual | |
71 | ' | |
72 | ||
f659031c | 73 | test_expect_success 'rev-list --ancestry-path D..M -- M.t' ' |
cb7529e1 JH |
74 | echo M >expect && |
75 | git rev-list --ancestry-path --format=%s D..M -- M.t | | |
76 | sed -e "/^commit /d" >actual && | |
77 | test_cmp expect actual | |
78 | ' | |
79 | ||
f659031c KB |
80 | test_expect_success 'rev-list F...I' ' |
81 | for c in F G H I; do echo $c; done >expect && | |
82 | git rev-list --format=%s F...I | | |
83 | sed -e "/^commit /d" | | |
84 | sort >actual && | |
85 | test_cmp expect actual | |
86 | ' | |
87 | ||
a765499a | 88 | test_expect_success 'rev-list --ancestry-path F...I' ' |
f659031c KB |
89 | for c in F H I; do echo $c; done >expect && |
90 | git rev-list --ancestry-path --format=%s F...I | | |
91 | sed -e "/^commit /d" | | |
92 | sort >actual && | |
93 | test_cmp expect actual | |
94 | ' | |
95 | ||
c72424b1 KB |
96 | # G.t is dropped in an "-s ours" merge |
97 | test_expect_success 'rev-list G..M -- G.t' ' | |
c72424b1 KB |
98 | git rev-list --format=%s G..M -- G.t | |
99 | sed -e "/^commit /d" >actual && | |
d3c6751b | 100 | test_must_be_empty actual |
c72424b1 KB |
101 | ' |
102 | ||
d0af663e | 103 | test_expect_success 'rev-list --ancestry-path G..M -- G.t' ' |
4d826608 | 104 | echo L >expect && |
c72424b1 | 105 | git rev-list --ancestry-path --format=%s G..M -- G.t | |
4d826608 KB |
106 | sed -e "/^commit /d" >actual && |
107 | test_cmp expect actual | |
108 | ' | |
109 | ||
110 | test_expect_success 'rev-list --ancestry-path --simplify-merges G^..M -- G.t' ' | |
111 | for c in G L; do echo $c; done >expect && | |
112 | git rev-list --ancestry-path --simplify-merges --format=%s G^..M -- G.t | | |
c72424b1 KB |
113 | sed -e "/^commit /d" | |
114 | sort >actual && | |
115 | test_cmp expect actual | |
116 | ' | |
117 | ||
81f49531 BK |
118 | # b---bc |
119 | # / \ / | |
120 | # a X | |
121 | # \ / \ | |
122 | # c---cb | |
c05b988a TR |
123 | # |
124 | # All refnames prefixed with 'x' to avoid confusion with the tags | |
125 | # generated by test_commit on case-insensitive systems. | |
81f49531 BK |
126 | test_expect_success 'setup criss-cross' ' |
127 | mkdir criss-cross && | |
128 | (cd criss-cross && | |
129 | git init && | |
130 | test_commit A && | |
c05b988a | 131 | git checkout -b xb master && |
81f49531 | 132 | test_commit B && |
c05b988a | 133 | git checkout -b xc master && |
81f49531 | 134 | test_commit C && |
c05b988a TR |
135 | git checkout -b xbc xb -- && |
136 | git merge xc && | |
137 | git checkout -b xcb xc -- && | |
138 | git merge xb && | |
81f49531 BK |
139 | git checkout master) |
140 | ' | |
141 | ||
142 | # no commits in bc descend from cb | |
143 | test_expect_success 'criss-cross: rev-list --ancestry-path cb..bc' ' | |
144 | (cd criss-cross && | |
c05b988a | 145 | git rev-list --ancestry-path xcb..xbc > actual && |
81f49531 BK |
146 | test -z "$(cat actual)") |
147 | ' | |
148 | ||
149 | # no commits in repository descend from cb | |
c3502fa8 | 150 | test_expect_success 'criss-cross: rev-list --ancestry-path --all ^cb' ' |
81f49531 | 151 | (cd criss-cross && |
c05b988a | 152 | git rev-list --ancestry-path --all ^xcb > actual && |
81f49531 BK |
153 | test -z "$(cat actual)") |
154 | ' | |
155 | ||
ebdc94f3 | 156 | test_done |