Commit | Line | Data |
---|---|---|
abdea96e KB |
1 | #!/bin/sh |
2 | # | |
3 | # ,---E--. *H----------. * marks !TREESAME parent paths | |
4 | # / \ / \* | |
5 | # *A--*B---D--*F-*G---------K-*L-*M | |
6 | # \ /* \ / | |
7 | # `-C-' `-*I-*J | |
8 | # | |
9 | # A creates "file", B and F change it. | |
10 | # Odd merge G takes the old version from B. | |
11 | # I changes it, but J reverts it, so K is TREESAME to both parents. | |
12 | # H and L both change "file", and M merges those changes. | |
13 | ||
14 | test_description='TREESAME and limiting' | |
15 | ||
16 | . ./test-lib.sh | |
17 | ||
18 | note () { | |
19 | git tag "$1" | |
20 | } | |
21 | ||
22 | unnote () { | |
e16f434a | 23 | git name-rev --tags --stdin | sed -e "s|$_x40 (tags/\([^)]*\))\([ ]\)|\1\2|g" |
abdea96e KB |
24 | } |
25 | ||
26 | test_expect_success setup ' | |
27 | test_commit "Initial file" file "Hi there" A && | |
28 | git branch other-branch && | |
29 | ||
30 | test_commit "file=Hello" file "Hello" B && | |
31 | git branch third-branch && | |
32 | ||
33 | git checkout other-branch && | |
34 | test_commit "Added other" other "Hello" C && | |
35 | ||
36 | git checkout master && | |
37 | test_merge D other-branch && | |
38 | ||
39 | git checkout third-branch && | |
40 | test_commit "Third file" third "Nothing" E && | |
41 | ||
42 | git checkout master && | |
43 | test_commit "file=Blah" file "Blah" F && | |
44 | ||
45 | test_tick && git merge --no-commit third-branch && | |
46 | git checkout third-branch file && | |
47 | git commit && | |
48 | note G && | |
49 | git branch fiddler-branch && | |
50 | ||
51 | git checkout -b part2-branch && | |
52 | test_commit "file=Part 2" file "Part 2" H && | |
53 | ||
54 | git checkout fiddler-branch && | |
55 | test_commit "Bad commit" file "Silly" I && | |
56 | ||
57 | test_tick && git revert I && note J && | |
58 | ||
59 | git checkout master && | |
60 | test_tick && git merge --no-ff fiddler-branch && | |
99094a7a | 61 | note K && |
abdea96e KB |
62 | |
63 | test_commit "file=Part 1" file "Part 1" L && | |
64 | ||
65 | test_tick && test_must_fail git merge part2-branch && | |
66 | test_commit M file "Parts 1+2" | |
67 | ' | |
68 | ||
abdea96e KB |
69 | check_outcome () { |
70 | outcome=$1 | |
71 | shift | |
e16f434a JH |
72 | |
73 | case "$1" in | |
74 | *"("*) | |
75 | FMT="%P %H | %s" | |
76 | munge_actual=" | |
77 | s/^\([^ ]*\) \([^ ]*\) .*/(\1)\2/ | |
78 | s/ //g | |
79 | s/()// | |
80 | " | |
81 | ;; | |
82 | *) | |
83 | FMT="%H | %s" | |
84 | munge_actual="s/^\([^ ]*\) .*/\1/" | |
85 | ;; | |
86 | esac && | |
87 | printf "%s\n" $1 >expect && | |
88 | shift | |
89 | ||
abdea96e KB |
90 | param="$*" && |
91 | test_expect_$outcome "log $param" ' | |
92 | git log --format="$FMT" $param | | |
93 | unnote >actual && | |
e16f434a | 94 | sed -e "$munge_actual" <actual >check && |
5ca812a1 | 95 | test_cmp expect check |
abdea96e KB |
96 | ' |
97 | } | |
98 | ||
99 | check_result () { | |
100 | check_outcome success "$@" | |
101 | } | |
102 | ||
103 | # Odd merge G drops a change in F. Important that G is listed in all | |
104 | # except the most basic list. Achieving this means normal merge D will also be | |
105 | # shown in normal full-history, as we can't distinguish unless we do a | |
106 | # simplification pass. After simplification, D is dropped but G remains. | |
53e38358 KB |
107 | # Also, merge simplification of G should not drop the parent B that the default |
108 | # simple history follows. | |
abdea96e | 109 | check_result 'M L K J I H G F E D C B A' |
e16f434a | 110 | check_result '(LH)M (K)L (GJ)K (I)J (G)I (G)H (FE)G (D)F (B)E (BC)D (A)C (A)B A' |
abdea96e KB |
111 | check_result 'M H L K J I G E F D C B A' --topo-order |
112 | check_result 'M L H B A' -- file | |
53e38358 | 113 | check_result '(LH)M (B)L (B)H (A)B A' --parents -- file |
d0af663e | 114 | check_result 'M L J I H G F D B A' --full-history -- file |
53e38358 | 115 | check_result '(LH)M (K)L (GJ)K (I)J (G)I (G)H (FB)G (D)F (BA)D (A)B A' --full-history --parents -- file |
9c129eab | 116 | check_result '(LH)M (G)H (J)L (I)J (G)I (FB)G (B)F (A)B A' --simplify-merges -- file |
abdea96e KB |
117 | check_result 'M L K G F D B A' --first-parent |
118 | check_result 'M L G F B A' --first-parent -- file | |
119 | ||
120 | # Check that odd merge G remains shown when F is the bottom. | |
121 | check_result 'M L K J I H G E' F..M | |
122 | check_result 'M H L K J I G E' F..M --topo-order | |
123 | check_result 'M L H' F..M -- file | |
53e38358 | 124 | check_result '(LH)M (B)L (B)H' --parents F..M -- file |
d0af663e | 125 | check_result 'M L J I H G' F..M --full-history -- file |
53e38358 | 126 | check_result '(LH)M (K)L (GJ)K (I)J (G)I (G)H (FB)G' F..M --full-history --parents -- file |
9c129eab | 127 | check_result '(LH)M (G)H (J)L (I)J (G)I (FB)G' F..M --simplify-merges -- file |
abdea96e | 128 | check_result 'M L K J I H G' F..M --ancestry-path |
d0af663e | 129 | check_result 'M L J I H G' F..M --ancestry-path -- file |
53e38358 KB |
130 | check_result '(LH)M (K)L (GJ)K (I)J (G)I (G)H (FE)G' F..M --ancestry-path --parents -- file |
131 | check_result '(LH)M (G)H (J)L (I)J (G)I (FE)G' F..M --ancestry-path --simplify-merges -- file | |
abdea96e KB |
132 | check_result 'M L K G' F..M --first-parent |
133 | check_result 'M L G' F..M --first-parent -- file | |
134 | ||
135 | # Note that G is pruned when E is the bottom, even if it's the same commit list | |
136 | # If we want history since E, then we're quite happy to ignore G that took E. | |
137 | check_result 'M L K J I H G' E..M --ancestry-path | |
4d826608 | 138 | check_result 'M L J I H' E..M --ancestry-path -- file |
bf3418b0 | 139 | check_result '(LH)M (K)L (EJ)K (I)J (E)I (E)H' E..M --ancestry-path --parents -- file |
4d826608 | 140 | check_result '(LH)M (E)H (J)L (I)J (E)I' E..M --ancestry-path --simplify-merges -- file |
abdea96e KB |
141 | |
142 | # Should still be able to ignore I-J branch in simple log, despite limiting | |
143 | # to G. | |
144 | check_result 'M L K J I H' G..M | |
145 | check_result 'M H L K J I' G..M --topo-order | |
141efdba KB |
146 | check_result 'M L H' G..M -- file |
147 | check_result '(LH)M (G)L (G)H' G..M --parents -- file | |
abdea96e KB |
148 | check_result 'M L J I H' G..M --full-history -- file |
149 | check_result 'M L K J I H' G..M --full-history --parents -- file | |
150 | check_result 'M H L J I' G..M --simplify-merges -- file | |
151 | check_result 'M L K J I H' G..M --ancestry-path | |
152 | check_result 'M L J I H' G..M --ancestry-path -- file | |
153 | check_result 'M L K J I H' G..M --ancestry-path --parents -- file | |
154 | check_result 'M H L J I' G..M --ancestry-path --simplify-merges -- file | |
155 | ||
156 | # B..F should be able to simplify the merge D from irrelevant side branch C. | |
157 | # Default log should also be free to follow B-D, and ignore C. | |
158 | # But --full-history shouldn't drop D on its own - without simplification, | |
159 | # we can't decide if the merge from INTERESTING commit C was sensible. | |
160 | check_result 'F D C' B..F | |
141efdba KB |
161 | check_result 'F' B..F -- file |
162 | check_result '(B)F' B..F --parents -- file | |
d0af663e | 163 | check_result 'F D' B..F --full-history -- file |
53e38358 KB |
164 | check_result '(D)F (BA)D' B..F --full-history --parents -- file |
165 | check_result '(B)F' B..F --simplify-merges -- file | |
abdea96e | 166 | check_result 'F D' B..F --ancestry-path |
4d826608 | 167 | check_result 'F' B..F --ancestry-path -- file |
bf3418b0 | 168 | check_result 'F' B..F --ancestry-path --parents -- file |
4d826608 | 169 | check_result 'F' B..F --ancestry-path --simplify-merges -- file |
abdea96e KB |
170 | check_result 'F D' B..F --first-parent |
171 | check_result 'F' B..F --first-parent -- file | |
172 | ||
173 | # E...F should be equivalent to E F ^B, and be able to drop D as above. | |
141efdba KB |
174 | check_result 'F' E F ^B -- file # includes D |
175 | check_result 'F' E...F -- file # includes D | |
abdea96e KB |
176 | |
177 | # Any sort of full history of C..F should show D, as it's the connection to C, | |
178 | # and it differs from it. | |
179 | check_result 'F D B' C..F | |
180 | check_result 'F B' C..F -- file | |
53e38358 | 181 | check_result '(B)F (A)B' C..F --parents -- file |
d0af663e | 182 | check_result 'F D B' C..F --full-history -- file |
53e38358 KB |
183 | check_result '(D)F (BC)D (A)B' C..F --full-history --parents -- file |
184 | check_result '(D)F (BC)D (A)B' C..F --simplify-merges -- file | |
abdea96e | 185 | check_result 'F D' C..F --ancestry-path |
d0af663e | 186 | check_result 'F D' C..F --ancestry-path -- file |
abdea96e KB |
187 | check_result 'F D' C..F --ancestry-path --parents -- file |
188 | check_result 'F D' C..F --ancestry-path --simplify-merges -- file | |
189 | check_result 'F D B' C..F --first-parent | |
190 | check_result 'F B' C..F --first-parent -- file | |
191 | ||
192 | ||
193 | test_done |