Thomas Rast | 8884cf1 | 2018-08-13 04:33:16 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='range-diff tests' |
| 4 | |
Johannes Schindelin | d6c6b10 | 2020-11-18 23:44:23 +0000 | [diff] [blame] | 5 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
Johannes Schindelin | 334afbc | 2020-11-18 23:44:19 +0000 | [diff] [blame] | 6 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
| 7 | |
Thomas Rast | 8884cf1 | 2018-08-13 04:33:16 -0700 | [diff] [blame] | 8 | . ./test-lib.sh |
| 9 | |
| 10 | # Note that because of the range-diff's heuristics, test_commit does more |
| 11 | # harm than good. We need some real history. |
| 12 | |
| 13 | test_expect_success 'setup' ' |
Denton Liu | 3a6e48e | 2019-11-20 13:18:33 -0800 | [diff] [blame] | 14 | git fast-import <"$TEST_DIRECTORY"/t3206/history.export && |
Denton Liu | 79f3950 | 2019-11-20 13:18:36 -0800 | [diff] [blame] | 15 | test_oid_cache <<-\EOF |
brian m. carlson | b561edd | 2019-08-18 19:16:34 +0000 | [diff] [blame] | 16 | # topic |
| 17 | t1 sha1:4de457d |
| 18 | t2 sha1:fccce22 |
| 19 | t3 sha1:147e64e |
| 20 | t4 sha1:a63e992 |
| 21 | t1 sha256:b89f8b9 |
| 22 | t2 sha256:5f12aad |
| 23 | t3 sha256:ea8b273 |
| 24 | t4 sha256:14b7336 |
| 25 | |
| 26 | # unmodified |
| 27 | u1 sha1:35b9b25 |
| 28 | u2 sha1:de345ab |
| 29 | u3 sha1:9af6654 |
| 30 | u4 sha1:2901f77 |
| 31 | u1 sha256:e3731be |
| 32 | u2 sha256:14fadf8 |
| 33 | u3 sha256:736c4bc |
| 34 | u4 sha256:673e77d |
| 35 | |
Teng Long | 2b15969 | 2023-02-20 22:24:44 +0800 | [diff] [blame] | 36 | # topic (abbrev=10) |
| 37 | t1_abbrev sha1:4de457d2c0 |
| 38 | t2_abbrev sha1:fccce22f8c |
| 39 | t3_abbrev sha1:147e64ef53 |
| 40 | t4_abbrev sha1:a63e992599 |
| 41 | t1_abbrev sha256:b89f8b9092 |
| 42 | t2_abbrev sha256:5f12aadf34 |
| 43 | t3_abbrev sha256:ea8b273a6c |
| 44 | t4_abbrev sha256:14b73361fc |
| 45 | |
| 46 | # unmodified (abbrev=10) |
| 47 | u1_abbrev sha1:35b9b25f76 |
| 48 | u2_abbrev sha1:de345ab3de |
| 49 | u3_abbrev sha1:9af6654000 |
| 50 | u4_abbrev sha1:2901f773f3 |
| 51 | u1_abbrev sha256:e3731be242 |
| 52 | u2_abbrev sha256:14fadf8cee |
| 53 | u3_abbrev sha256:736c4bcb44 |
| 54 | u4_abbrev sha256:673e77d589 |
| 55 | |
brian m. carlson | b561edd | 2019-08-18 19:16:34 +0000 | [diff] [blame] | 56 | # reordered |
| 57 | r1 sha1:aca177a |
| 58 | r2 sha1:14ad629 |
| 59 | r3 sha1:ee58208 |
| 60 | r4 sha1:307b27a |
| 61 | r1 sha256:f59d3aa |
| 62 | r2 sha256:fb261a8 |
| 63 | r3 sha256:cb2649b |
| 64 | r4 sha256:958577e |
| 65 | |
| 66 | # removed (deleted) |
| 67 | d1 sha1:7657159 |
| 68 | d2 sha1:43d84d3 |
| 69 | d3 sha1:a740396 |
| 70 | d1 sha256:e312513 |
| 71 | d2 sha256:eb19258 |
| 72 | d3 sha256:1ccb3c1 |
| 73 | |
| 74 | # added |
| 75 | a1 sha1:2716022 |
| 76 | a2 sha1:b62accd |
| 77 | a3 sha1:df46cfa |
| 78 | a4 sha1:3e64548 |
| 79 | a5 sha1:12b4063 |
| 80 | a1 sha256:d724f4d |
| 81 | a2 sha256:1de7762 |
| 82 | a3 sha256:e159431 |
| 83 | a4 sha256:b3e483c |
| 84 | a5 sha256:90866a7 |
| 85 | |
| 86 | # rebased |
| 87 | b1 sha1:cc9c443 |
| 88 | b2 sha1:c5d9641 |
| 89 | b3 sha1:28cc2b6 |
| 90 | b4 sha1:5628ab7 |
| 91 | b5 sha1:a31b12e |
| 92 | b1 sha256:a1a8717 |
| 93 | b2 sha256:20a5862 |
| 94 | b3 sha256:587172a |
| 95 | b4 sha256:2721c5d |
| 96 | b5 sha256:7b57864 |
| 97 | |
| 98 | # changed |
| 99 | c1 sha1:a4b3333 |
| 100 | c2 sha1:f51d370 |
| 101 | c3 sha1:0559556 |
| 102 | c4 sha1:d966c5c |
| 103 | c1 sha256:f8c2b9d |
| 104 | c2 sha256:3fb6318 |
| 105 | c3 sha256:168ab68 |
| 106 | c4 sha256:3526539 |
| 107 | |
| 108 | # changed-message |
| 109 | m1 sha1:f686024 |
| 110 | m2 sha1:4ab067d |
| 111 | m3 sha1:b9cb956 |
| 112 | m4 sha1:8add5f1 |
| 113 | m1 sha256:31e6281 |
| 114 | m2 sha256:a06bf1b |
| 115 | m3 sha256:82dc654 |
| 116 | m4 sha256:48470c5 |
| 117 | |
| 118 | # renamed |
| 119 | n1 sha1:f258d75 |
| 120 | n2 sha1:017b62d |
| 121 | n3 sha1:3ce7af6 |
| 122 | n4 sha1:1e6226b |
| 123 | n1 sha256:ad52114 |
| 124 | n2 sha256:3b54c8f |
| 125 | n3 sha256:3b0a644 |
| 126 | n4 sha256:e461653 |
| 127 | |
brian m. carlson | 94db7e3 | 2020-02-07 00:52:35 +0000 | [diff] [blame] | 128 | # mode change |
| 129 | o1 sha1:4d39cb3 |
| 130 | o2 sha1:26c107f |
| 131 | o3 sha1:4c1e0f5 |
| 132 | o1 sha256:d0dd598 |
| 133 | o2 sha256:c4a279e |
| 134 | o3 sha256:78459d7 |
| 135 | |
brian m. carlson | b561edd | 2019-08-18 19:16:34 +0000 | [diff] [blame] | 136 | # added and removed |
| 137 | s1 sha1:096b1ba |
| 138 | s2 sha1:d92e698 |
| 139 | s3 sha1:9a1db4d |
| 140 | s4 sha1:fea3b5c |
| 141 | s1 sha256:a7f9134 |
| 142 | s2 sha256:b4c2580 |
| 143 | s3 sha256:1d62aa2 |
| 144 | s4 sha256:48160e8 |
| 145 | |
| 146 | # Empty delimiter (included so lines match neatly) |
| 147 | __ sha1:------- |
| 148 | __ sha256:------- |
| 149 | EOF |
Thomas Rast | 8884cf1 | 2018-08-13 04:33:16 -0700 | [diff] [blame] | 150 | ' |
| 151 | |
| 152 | test_expect_success 'simple A..B A..C (unmodified)' ' |
Johannes Schindelin | d6c6b10 | 2020-11-18 23:44:23 +0000 | [diff] [blame] | 153 | git range-diff --no-color main..topic main..unmodified \ |
Thomas Rast | 8884cf1 | 2018-08-13 04:33:16 -0700 | [diff] [blame] | 154 | >actual && |
Denton Liu | 75c5aa0 | 2019-11-20 13:18:38 -0800 | [diff] [blame] | 155 | cat >expect <<-EOF && |
brian m. carlson | b561edd | 2019-08-18 19:16:34 +0000 | [diff] [blame] | 156 | 1: $(test_oid t1) = 1: $(test_oid u1) s/5/A/ |
| 157 | 2: $(test_oid t2) = 2: $(test_oid u2) s/4/A/ |
| 158 | 3: $(test_oid t3) = 3: $(test_oid u3) s/11/B/ |
| 159 | 4: $(test_oid t4) = 4: $(test_oid u4) s/12/B/ |
Thomas Rast | 8884cf1 | 2018-08-13 04:33:16 -0700 | [diff] [blame] | 160 | EOF |
Denton Liu | 75c5aa0 | 2019-11-20 13:18:38 -0800 | [diff] [blame] | 161 | test_cmp expect actual |
Thomas Rast | 8884cf1 | 2018-08-13 04:33:16 -0700 | [diff] [blame] | 162 | ' |
| 163 | |
| 164 | test_expect_success 'simple B...C (unmodified)' ' |
| 165 | git range-diff --no-color topic...unmodified >actual && |
Denton Liu | 75c5aa0 | 2019-11-20 13:18:38 -0800 | [diff] [blame] | 166 | # same "expect" as above |
| 167 | test_cmp expect actual |
Thomas Rast | 8884cf1 | 2018-08-13 04:33:16 -0700 | [diff] [blame] | 168 | ' |
| 169 | |
| 170 | test_expect_success 'simple A B C (unmodified)' ' |
Johannes Schindelin | d6c6b10 | 2020-11-18 23:44:23 +0000 | [diff] [blame] | 171 | git range-diff --no-color main topic unmodified >actual && |
Denton Liu | 75c5aa0 | 2019-11-20 13:18:38 -0800 | [diff] [blame] | 172 | # same "expect" as above |
| 173 | test_cmp expect actual |
Thomas Rast | 8884cf1 | 2018-08-13 04:33:16 -0700 | [diff] [blame] | 174 | ' |
| 175 | |
Teng Long | 2b15969 | 2023-02-20 22:24:44 +0800 | [diff] [blame] | 176 | test_expect_success 'simple A..B A..C (unmodified) with --abbrev' ' |
| 177 | git range-diff --no-color --abbrev=10 main..topic main..unmodified \ |
| 178 | >actual && |
| 179 | cat >expect <<-EOF && |
| 180 | 1: $(test_oid t1_abbrev) = 1: $(test_oid u1_abbrev) s/5/A/ |
| 181 | 2: $(test_oid t2_abbrev) = 2: $(test_oid u2_abbrev) s/4/A/ |
| 182 | 3: $(test_oid t3_abbrev) = 3: $(test_oid u3_abbrev) s/11/B/ |
| 183 | 4: $(test_oid t4_abbrev) = 4: $(test_oid u4_abbrev) s/12/B/ |
| 184 | EOF |
| 185 | test_cmp expect actual |
| 186 | ' |
| 187 | |
Johannes Schindelin | 359f0d7 | 2021-02-05 14:44:48 +0000 | [diff] [blame] | 188 | test_expect_success 'A^! and A^-<n> (unmodified)' ' |
| 189 | git range-diff --no-color topic^! unmodified^-1 >actual && |
| 190 | cat >expect <<-EOF && |
| 191 | 1: $(test_oid t4) = 1: $(test_oid u4) s/12/B/ |
| 192 | EOF |
| 193 | test_cmp expect actual |
| 194 | ' |
| 195 | |
| 196 | test_expect_success 'A^{/..} is not mistaken for a range' ' |
Johannes Schindelin | b757478 | 2022-08-26 09:39:30 +0000 | [diff] [blame] | 197 | test_must_fail git range-diff topic^.. topic^{/..} -- 2>error && |
Junio C Hamano | 6789275 | 2023-10-31 14:23:30 +0900 | [diff] [blame] | 198 | test_grep "not a commit range" error |
Johannes Schindelin | 359f0d7 | 2021-02-05 14:44:48 +0000 | [diff] [blame] | 199 | ' |
| 200 | |
Thomas Rast | 8884cf1 | 2018-08-13 04:33:16 -0700 | [diff] [blame] | 201 | test_expect_success 'trivial reordering' ' |
Johannes Schindelin | d6c6b10 | 2020-11-18 23:44:23 +0000 | [diff] [blame] | 202 | git range-diff --no-color main topic reordered >actual && |
Denton Liu | 75c5aa0 | 2019-11-20 13:18:38 -0800 | [diff] [blame] | 203 | cat >expect <<-EOF && |
brian m. carlson | b561edd | 2019-08-18 19:16:34 +0000 | [diff] [blame] | 204 | 1: $(test_oid t1) = 1: $(test_oid r1) s/5/A/ |
| 205 | 3: $(test_oid t3) = 2: $(test_oid r2) s/11/B/ |
| 206 | 4: $(test_oid t4) = 3: $(test_oid r3) s/12/B/ |
| 207 | 2: $(test_oid t2) = 4: $(test_oid r4) s/4/A/ |
Thomas Rast | 8884cf1 | 2018-08-13 04:33:16 -0700 | [diff] [blame] | 208 | EOF |
Denton Liu | 75c5aa0 | 2019-11-20 13:18:38 -0800 | [diff] [blame] | 209 | test_cmp expect actual |
Thomas Rast | 8884cf1 | 2018-08-13 04:33:16 -0700 | [diff] [blame] | 210 | ' |
| 211 | |
| 212 | test_expect_success 'removed a commit' ' |
Johannes Schindelin | d6c6b10 | 2020-11-18 23:44:23 +0000 | [diff] [blame] | 213 | git range-diff --no-color main topic removed >actual && |
Denton Liu | 75c5aa0 | 2019-11-20 13:18:38 -0800 | [diff] [blame] | 214 | cat >expect <<-EOF && |
brian m. carlson | b561edd | 2019-08-18 19:16:34 +0000 | [diff] [blame] | 215 | 1: $(test_oid t1) = 1: $(test_oid d1) s/5/A/ |
| 216 | 2: $(test_oid t2) < -: $(test_oid __) s/4/A/ |
| 217 | 3: $(test_oid t3) = 2: $(test_oid d2) s/11/B/ |
| 218 | 4: $(test_oid t4) = 3: $(test_oid d3) s/12/B/ |
Thomas Rast | 8884cf1 | 2018-08-13 04:33:16 -0700 | [diff] [blame] | 219 | EOF |
Denton Liu | 75c5aa0 | 2019-11-20 13:18:38 -0800 | [diff] [blame] | 220 | test_cmp expect actual |
Thomas Rast | 8884cf1 | 2018-08-13 04:33:16 -0700 | [diff] [blame] | 221 | ' |
| 222 | |
| 223 | test_expect_success 'added a commit' ' |
Johannes Schindelin | d6c6b10 | 2020-11-18 23:44:23 +0000 | [diff] [blame] | 224 | git range-diff --no-color main topic added >actual && |
Denton Liu | 75c5aa0 | 2019-11-20 13:18:38 -0800 | [diff] [blame] | 225 | cat >expect <<-EOF && |
brian m. carlson | b561edd | 2019-08-18 19:16:34 +0000 | [diff] [blame] | 226 | 1: $(test_oid t1) = 1: $(test_oid a1) s/5/A/ |
| 227 | 2: $(test_oid t2) = 2: $(test_oid a2) s/4/A/ |
| 228 | -: $(test_oid __) > 3: $(test_oid a3) s/6/A/ |
| 229 | 3: $(test_oid t3) = 4: $(test_oid a4) s/11/B/ |
| 230 | 4: $(test_oid t4) = 5: $(test_oid a5) s/12/B/ |
Thomas Rast | 8884cf1 | 2018-08-13 04:33:16 -0700 | [diff] [blame] | 231 | EOF |
Denton Liu | 75c5aa0 | 2019-11-20 13:18:38 -0800 | [diff] [blame] | 232 | test_cmp expect actual |
Thomas Rast | 8884cf1 | 2018-08-13 04:33:16 -0700 | [diff] [blame] | 233 | ' |
| 234 | |
| 235 | test_expect_success 'new base, A B C' ' |
Johannes Schindelin | d6c6b10 | 2020-11-18 23:44:23 +0000 | [diff] [blame] | 236 | git range-diff --no-color main topic rebased >actual && |
Denton Liu | 75c5aa0 | 2019-11-20 13:18:38 -0800 | [diff] [blame] | 237 | cat >expect <<-EOF && |
brian m. carlson | b561edd | 2019-08-18 19:16:34 +0000 | [diff] [blame] | 238 | 1: $(test_oid t1) = 1: $(test_oid b1) s/5/A/ |
| 239 | 2: $(test_oid t2) = 2: $(test_oid b2) s/4/A/ |
| 240 | 3: $(test_oid t3) = 3: $(test_oid b3) s/11/B/ |
| 241 | 4: $(test_oid t4) = 4: $(test_oid b4) s/12/B/ |
Thomas Rast | 8884cf1 | 2018-08-13 04:33:16 -0700 | [diff] [blame] | 242 | EOF |
Denton Liu | 75c5aa0 | 2019-11-20 13:18:38 -0800 | [diff] [blame] | 243 | test_cmp expect actual |
Thomas Rast | 8884cf1 | 2018-08-13 04:33:16 -0700 | [diff] [blame] | 244 | ' |
| 245 | |
| 246 | test_expect_success 'new base, B...C' ' |
Johannes Schindelin | d6c6b10 | 2020-11-18 23:44:23 +0000 | [diff] [blame] | 247 | # this syntax includes the commits from main! |
Thomas Rast | 8884cf1 | 2018-08-13 04:33:16 -0700 | [diff] [blame] | 248 | git range-diff --no-color topic...rebased >actual && |
Denton Liu | 75c5aa0 | 2019-11-20 13:18:38 -0800 | [diff] [blame] | 249 | cat >expect <<-EOF && |
brian m. carlson | b561edd | 2019-08-18 19:16:34 +0000 | [diff] [blame] | 250 | -: $(test_oid __) > 1: $(test_oid b5) unrelated |
| 251 | 1: $(test_oid t1) = 2: $(test_oid b1) s/5/A/ |
| 252 | 2: $(test_oid t2) = 3: $(test_oid b2) s/4/A/ |
| 253 | 3: $(test_oid t3) = 4: $(test_oid b3) s/11/B/ |
| 254 | 4: $(test_oid t4) = 5: $(test_oid b4) s/12/B/ |
Thomas Rast | 8884cf1 | 2018-08-13 04:33:16 -0700 | [diff] [blame] | 255 | EOF |
Denton Liu | 75c5aa0 | 2019-11-20 13:18:38 -0800 | [diff] [blame] | 256 | test_cmp expect actual |
Thomas Rast | 8884cf1 | 2018-08-13 04:33:16 -0700 | [diff] [blame] | 257 | ' |
| 258 | |
| 259 | test_expect_success 'changed commit' ' |
| 260 | git range-diff --no-color topic...changed >actual && |
Denton Liu | 75c5aa0 | 2019-11-20 13:18:38 -0800 | [diff] [blame] | 261 | cat >expect <<-EOF && |
brian m. carlson | b561edd | 2019-08-18 19:16:34 +0000 | [diff] [blame] | 262 | 1: $(test_oid t1) = 1: $(test_oid c1) s/5/A/ |
| 263 | 2: $(test_oid t2) = 2: $(test_oid c2) s/4/A/ |
| 264 | 3: $(test_oid t3) ! 3: $(test_oid c3) s/11/B/ |
Thomas Gummerer | 499352c | 2019-07-11 17:08:51 +0100 | [diff] [blame] | 265 | @@ file: A |
Thomas Rast | 8884cf1 | 2018-08-13 04:33:16 -0700 | [diff] [blame] | 266 | 9 |
| 267 | 10 |
| 268 | -11 |
| 269 | -+B |
| 270 | ++BB |
| 271 | 12 |
| 272 | 13 |
| 273 | 14 |
brian m. carlson | b561edd | 2019-08-18 19:16:34 +0000 | [diff] [blame] | 274 | 4: $(test_oid t4) ! 4: $(test_oid c4) s/12/B/ |
Thomas Gummerer | 499352c | 2019-07-11 17:08:51 +0100 | [diff] [blame] | 275 | @@ file |
Thomas Gummerer | 444e096 | 2019-07-11 17:08:50 +0100 | [diff] [blame] | 276 | @@ file: A |
Thomas Rast | 8884cf1 | 2018-08-13 04:33:16 -0700 | [diff] [blame] | 277 | 9 |
| 278 | 10 |
| 279 | - B |
| 280 | + BB |
| 281 | -12 |
| 282 | +B |
| 283 | 13 |
| 284 | EOF |
Denton Liu | 75c5aa0 | 2019-11-20 13:18:38 -0800 | [diff] [blame] | 285 | test_cmp expect actual |
Thomas Rast | 8884cf1 | 2018-08-13 04:33:16 -0700 | [diff] [blame] | 286 | ' |
| 287 | |
Ævar Arnfjörð Bjarmason | 4624185 | 2018-11-09 10:18:02 +0000 | [diff] [blame] | 288 | test_expect_success 'changed commit with --no-patch diff option' ' |
| 289 | git range-diff --no-color --no-patch topic...changed >actual && |
Denton Liu | 75c5aa0 | 2019-11-20 13:18:38 -0800 | [diff] [blame] | 290 | cat >expect <<-EOF && |
brian m. carlson | b561edd | 2019-08-18 19:16:34 +0000 | [diff] [blame] | 291 | 1: $(test_oid t1) = 1: $(test_oid c1) s/5/A/ |
| 292 | 2: $(test_oid t2) = 2: $(test_oid c2) s/4/A/ |
| 293 | 3: $(test_oid t3) ! 3: $(test_oid c3) s/11/B/ |
| 294 | 4: $(test_oid t4) ! 4: $(test_oid c4) s/12/B/ |
Ævar Arnfjörð Bjarmason | 4624185 | 2018-11-09 10:18:02 +0000 | [diff] [blame] | 295 | EOF |
Denton Liu | 75c5aa0 | 2019-11-20 13:18:38 -0800 | [diff] [blame] | 296 | test_cmp expect actual |
Ævar Arnfjörð Bjarmason | 4624185 | 2018-11-09 10:18:02 +0000 | [diff] [blame] | 297 | ' |
| 298 | |
| 299 | test_expect_success 'changed commit with --stat diff option' ' |
Ævar Arnfjörð Bjarmason | 4624185 | 2018-11-09 10:18:02 +0000 | [diff] [blame] | 300 | git range-diff --no-color --stat topic...changed >actual && |
Denton Liu | 75c5aa0 | 2019-11-20 13:18:38 -0800 | [diff] [blame] | 301 | cat >expect <<-EOF && |
brian m. carlson | b561edd | 2019-08-18 19:16:34 +0000 | [diff] [blame] | 302 | 1: $(test_oid t1) = 1: $(test_oid c1) s/5/A/ |
brian m. carlson | b561edd | 2019-08-18 19:16:34 +0000 | [diff] [blame] | 303 | 2: $(test_oid t2) = 2: $(test_oid c2) s/4/A/ |
brian m. carlson | b561edd | 2019-08-18 19:16:34 +0000 | [diff] [blame] | 304 | 3: $(test_oid t3) ! 3: $(test_oid c3) s/11/B/ |
Thomas Guyot-Sionnest | ff0c7fa | 2020-09-24 03:41:41 -0400 | [diff] [blame] | 305 | a => b | 2 +- |
| 306 | 1 file changed, 1 insertion(+), 1 deletion(-) |
brian m. carlson | b561edd | 2019-08-18 19:16:34 +0000 | [diff] [blame] | 307 | 4: $(test_oid t4) ! 4: $(test_oid c4) s/12/B/ |
Thomas Guyot-Sionnest | ff0c7fa | 2020-09-24 03:41:41 -0400 | [diff] [blame] | 308 | a => b | 2 +- |
| 309 | 1 file changed, 1 insertion(+), 1 deletion(-) |
Ævar Arnfjörð Bjarmason | 4624185 | 2018-11-09 10:18:02 +0000 | [diff] [blame] | 310 | EOF |
Denton Liu | 75c5aa0 | 2019-11-20 13:18:38 -0800 | [diff] [blame] | 311 | test_cmp expect actual |
Ævar Arnfjörð Bjarmason | 4624185 | 2018-11-09 10:18:02 +0000 | [diff] [blame] | 312 | ' |
| 313 | |
Lucas De Marchi | 0e573e8 | 2018-10-24 12:46:17 -0700 | [diff] [blame] | 314 | test_expect_success 'changed commit with sm config' ' |
| 315 | git range-diff --no-color --submodule=log topic...changed >actual && |
Denton Liu | 75c5aa0 | 2019-11-20 13:18:38 -0800 | [diff] [blame] | 316 | cat >expect <<-EOF && |
brian m. carlson | b561edd | 2019-08-18 19:16:34 +0000 | [diff] [blame] | 317 | 1: $(test_oid t1) = 1: $(test_oid c1) s/5/A/ |
| 318 | 2: $(test_oid t2) = 2: $(test_oid c2) s/4/A/ |
| 319 | 3: $(test_oid t3) ! 3: $(test_oid c3) s/11/B/ |
Thomas Gummerer | 499352c | 2019-07-11 17:08:51 +0100 | [diff] [blame] | 320 | @@ file: A |
Lucas De Marchi | 0e573e8 | 2018-10-24 12:46:17 -0700 | [diff] [blame] | 321 | 9 |
| 322 | 10 |
| 323 | -11 |
| 324 | -+B |
| 325 | ++BB |
| 326 | 12 |
| 327 | 13 |
| 328 | 14 |
brian m. carlson | b561edd | 2019-08-18 19:16:34 +0000 | [diff] [blame] | 329 | 4: $(test_oid t4) ! 4: $(test_oid c4) s/12/B/ |
Thomas Gummerer | 499352c | 2019-07-11 17:08:51 +0100 | [diff] [blame] | 330 | @@ file |
Thomas Gummerer | 444e096 | 2019-07-11 17:08:50 +0100 | [diff] [blame] | 331 | @@ file: A |
Lucas De Marchi | 0e573e8 | 2018-10-24 12:46:17 -0700 | [diff] [blame] | 332 | 9 |
| 333 | 10 |
| 334 | - B |
| 335 | + BB |
| 336 | -12 |
| 337 | +B |
| 338 | 13 |
| 339 | EOF |
Denton Liu | 75c5aa0 | 2019-11-20 13:18:38 -0800 | [diff] [blame] | 340 | test_cmp expect actual |
Lucas De Marchi | 0e573e8 | 2018-10-24 12:46:17 -0700 | [diff] [blame] | 341 | ' |
| 342 | |
Thomas Gummerer | b66885a | 2019-07-11 17:08:49 +0100 | [diff] [blame] | 343 | test_expect_success 'renamed file' ' |
| 344 | git range-diff --no-color --submodule=log topic...renamed-file >actual && |
Denton Liu | 75c5aa0 | 2019-11-20 13:18:38 -0800 | [diff] [blame] | 345 | sed s/Z/\ /g >expect <<-EOF && |
brian m. carlson | b561edd | 2019-08-18 19:16:34 +0000 | [diff] [blame] | 346 | 1: $(test_oid t1) = 1: $(test_oid n1) s/5/A/ |
| 347 | 2: $(test_oid t2) ! 2: $(test_oid n2) s/4/A/ |
Thomas Gummerer | 499352c | 2019-07-11 17:08:51 +0100 | [diff] [blame] | 348 | @@ Metadata |
Thomas Gummerer | b66885a | 2019-07-11 17:08:49 +0100 | [diff] [blame] | 349 | ZAuthor: Thomas Rast <trast@inf.ethz.ch> |
| 350 | Z |
Thomas Gummerer | 499352c | 2019-07-11 17:08:51 +0100 | [diff] [blame] | 351 | Z ## Commit message ## |
Thomas Gummerer | b66885a | 2019-07-11 17:08:49 +0100 | [diff] [blame] | 352 | - s/4/A/ |
| 353 | + s/4/A/ + rename file |
| 354 | Z |
| 355 | - ## file ## |
| 356 | + ## file => renamed-file ## |
| 357 | Z@@ |
| 358 | Z 1 |
| 359 | Z 2 |
brian m. carlson | b561edd | 2019-08-18 19:16:34 +0000 | [diff] [blame] | 360 | 3: $(test_oid t3) ! 3: $(test_oid n3) s/11/B/ |
Thomas Gummerer | 499352c | 2019-07-11 17:08:51 +0100 | [diff] [blame] | 361 | @@ Metadata |
| 362 | Z ## Commit message ## |
Thomas Gummerer | b66885a | 2019-07-11 17:08:49 +0100 | [diff] [blame] | 363 | Z s/11/B/ |
| 364 | Z |
| 365 | - ## file ## |
Thomas Gummerer | 444e096 | 2019-07-11 17:08:50 +0100 | [diff] [blame] | 366 | -@@ file: A |
Thomas Gummerer | b66885a | 2019-07-11 17:08:49 +0100 | [diff] [blame] | 367 | + ## renamed-file ## |
Thomas Gummerer | 444e096 | 2019-07-11 17:08:50 +0100 | [diff] [blame] | 368 | +@@ renamed-file: A |
Thomas Gummerer | b66885a | 2019-07-11 17:08:49 +0100 | [diff] [blame] | 369 | Z 8 |
| 370 | Z 9 |
Thomas Gummerer | 444e096 | 2019-07-11 17:08:50 +0100 | [diff] [blame] | 371 | Z 10 |
brian m. carlson | b561edd | 2019-08-18 19:16:34 +0000 | [diff] [blame] | 372 | 4: $(test_oid t4) ! 4: $(test_oid n4) s/12/B/ |
Thomas Gummerer | 499352c | 2019-07-11 17:08:51 +0100 | [diff] [blame] | 373 | @@ Metadata |
| 374 | Z ## Commit message ## |
Thomas Gummerer | b66885a | 2019-07-11 17:08:49 +0100 | [diff] [blame] | 375 | Z s/12/B/ |
| 376 | Z |
| 377 | - ## file ## |
Thomas Gummerer | 444e096 | 2019-07-11 17:08:50 +0100 | [diff] [blame] | 378 | -@@ file: A |
Thomas Gummerer | b66885a | 2019-07-11 17:08:49 +0100 | [diff] [blame] | 379 | + ## renamed-file ## |
Thomas Gummerer | 444e096 | 2019-07-11 17:08:50 +0100 | [diff] [blame] | 380 | +@@ renamed-file: A |
Thomas Gummerer | b66885a | 2019-07-11 17:08:49 +0100 | [diff] [blame] | 381 | Z 9 |
| 382 | Z 10 |
Thomas Gummerer | 444e096 | 2019-07-11 17:08:50 +0100 | [diff] [blame] | 383 | Z B |
Thomas Gummerer | b66885a | 2019-07-11 17:08:49 +0100 | [diff] [blame] | 384 | EOF |
Denton Liu | 75c5aa0 | 2019-11-20 13:18:38 -0800 | [diff] [blame] | 385 | test_cmp expect actual |
Thomas Gummerer | b66885a | 2019-07-11 17:08:49 +0100 | [diff] [blame] | 386 | ' |
| 387 | |
Thomas Gummerer | 2b6a9b1 | 2019-10-08 18:38:43 +0100 | [diff] [blame] | 388 | test_expect_success 'file with mode only change' ' |
| 389 | git range-diff --no-color --submodule=log topic...mode-only-change >actual && |
Denton Liu | 75c5aa0 | 2019-11-20 13:18:38 -0800 | [diff] [blame] | 390 | sed s/Z/\ /g >expect <<-EOF && |
brian m. carlson | 94db7e3 | 2020-02-07 00:52:35 +0000 | [diff] [blame] | 391 | 1: $(test_oid t2) ! 1: $(test_oid o1) s/4/A/ |
Thomas Gummerer | 2b6a9b1 | 2019-10-08 18:38:43 +0100 | [diff] [blame] | 392 | @@ Metadata |
| 393 | ZAuthor: Thomas Rast <trast@inf.ethz.ch> |
| 394 | Z |
| 395 | Z ## Commit message ## |
| 396 | - s/4/A/ |
| 397 | + s/4/A/ + add other-file |
| 398 | Z |
| 399 | Z ## file ## |
| 400 | Z@@ |
| 401 | @@ file |
| 402 | Z A |
| 403 | Z 6 |
| 404 | Z 7 |
| 405 | + |
| 406 | + ## other-file (new) ## |
brian m. carlson | 94db7e3 | 2020-02-07 00:52:35 +0000 | [diff] [blame] | 407 | 2: $(test_oid t3) ! 2: $(test_oid o2) s/11/B/ |
Thomas Gummerer | 2b6a9b1 | 2019-10-08 18:38:43 +0100 | [diff] [blame] | 408 | @@ Metadata |
| 409 | ZAuthor: Thomas Rast <trast@inf.ethz.ch> |
| 410 | Z |
| 411 | Z ## Commit message ## |
| 412 | - s/11/B/ |
| 413 | + s/11/B/ + mode change other-file |
| 414 | Z |
| 415 | Z ## file ## |
| 416 | Z@@ file: A |
| 417 | @@ file: A |
| 418 | Z 12 |
| 419 | Z 13 |
| 420 | Z 14 |
| 421 | + |
| 422 | + ## other-file (mode change 100644 => 100755) ## |
brian m. carlson | 94db7e3 | 2020-02-07 00:52:35 +0000 | [diff] [blame] | 423 | 3: $(test_oid t4) = 3: $(test_oid o3) s/12/B/ |
Thomas Gummerer | 2b6a9b1 | 2019-10-08 18:38:43 +0100 | [diff] [blame] | 424 | EOF |
Denton Liu | 75c5aa0 | 2019-11-20 13:18:38 -0800 | [diff] [blame] | 425 | test_cmp expect actual |
Thomas Gummerer | 2b6a9b1 | 2019-10-08 18:38:43 +0100 | [diff] [blame] | 426 | ' |
| 427 | |
Thomas Gummerer | b66885a | 2019-07-11 17:08:49 +0100 | [diff] [blame] | 428 | test_expect_success 'file added and later removed' ' |
| 429 | git range-diff --no-color --submodule=log topic...added-removed >actual && |
Denton Liu | 75c5aa0 | 2019-11-20 13:18:38 -0800 | [diff] [blame] | 430 | sed s/Z/\ /g >expect <<-EOF && |
brian m. carlson | b561edd | 2019-08-18 19:16:34 +0000 | [diff] [blame] | 431 | 1: $(test_oid t1) = 1: $(test_oid s1) s/5/A/ |
| 432 | 2: $(test_oid t2) ! 2: $(test_oid s2) s/4/A/ |
Thomas Gummerer | 499352c | 2019-07-11 17:08:51 +0100 | [diff] [blame] | 433 | @@ Metadata |
Thomas Gummerer | b66885a | 2019-07-11 17:08:49 +0100 | [diff] [blame] | 434 | ZAuthor: Thomas Rast <trast@inf.ethz.ch> |
| 435 | Z |
Thomas Gummerer | 499352c | 2019-07-11 17:08:51 +0100 | [diff] [blame] | 436 | Z ## Commit message ## |
Thomas Gummerer | b66885a | 2019-07-11 17:08:49 +0100 | [diff] [blame] | 437 | - s/4/A/ |
| 438 | + s/4/A/ + new-file |
| 439 | Z |
| 440 | Z ## file ## |
| 441 | Z@@ |
Thomas Gummerer | 499352c | 2019-07-11 17:08:51 +0100 | [diff] [blame] | 442 | @@ file |
Thomas Gummerer | b66885a | 2019-07-11 17:08:49 +0100 | [diff] [blame] | 443 | Z A |
| 444 | Z 6 |
| 445 | Z 7 |
| 446 | + |
| 447 | + ## new-file (new) ## |
brian m. carlson | b561edd | 2019-08-18 19:16:34 +0000 | [diff] [blame] | 448 | 3: $(test_oid t3) ! 3: $(test_oid s3) s/11/B/ |
Thomas Gummerer | 499352c | 2019-07-11 17:08:51 +0100 | [diff] [blame] | 449 | @@ Metadata |
Thomas Gummerer | b66885a | 2019-07-11 17:08:49 +0100 | [diff] [blame] | 450 | ZAuthor: Thomas Rast <trast@inf.ethz.ch> |
| 451 | Z |
Thomas Gummerer | 499352c | 2019-07-11 17:08:51 +0100 | [diff] [blame] | 452 | Z ## Commit message ## |
Thomas Gummerer | b66885a | 2019-07-11 17:08:49 +0100 | [diff] [blame] | 453 | - s/11/B/ |
| 454 | + s/11/B/ + remove file |
| 455 | Z |
| 456 | Z ## file ## |
Thomas Gummerer | 444e096 | 2019-07-11 17:08:50 +0100 | [diff] [blame] | 457 | Z@@ file: A |
Thomas Gummerer | 499352c | 2019-07-11 17:08:51 +0100 | [diff] [blame] | 458 | @@ file: A |
Thomas Gummerer | b66885a | 2019-07-11 17:08:49 +0100 | [diff] [blame] | 459 | Z 12 |
| 460 | Z 13 |
| 461 | Z 14 |
| 462 | + |
| 463 | + ## new-file (deleted) ## |
brian m. carlson | b561edd | 2019-08-18 19:16:34 +0000 | [diff] [blame] | 464 | 4: $(test_oid t4) = 4: $(test_oid s4) s/12/B/ |
Thomas Gummerer | b66885a | 2019-07-11 17:08:49 +0100 | [diff] [blame] | 465 | EOF |
Denton Liu | 75c5aa0 | 2019-11-20 13:18:38 -0800 | [diff] [blame] | 466 | test_cmp expect actual |
Thomas Gummerer | b66885a | 2019-07-11 17:08:49 +0100 | [diff] [blame] | 467 | ' |
| 468 | |
Junio C Hamano | 51bbcda | 2018-09-24 10:30:53 -0700 | [diff] [blame] | 469 | test_expect_success 'no commits on one side' ' |
| 470 | git commit --amend -m "new message" && |
Johannes Schindelin | d6c6b10 | 2020-11-18 23:44:23 +0000 | [diff] [blame] | 471 | git range-diff main HEAD@{1} HEAD |
Junio C Hamano | 51bbcda | 2018-09-24 10:30:53 -0700 | [diff] [blame] | 472 | ' |
| 473 | |
Thomas Rast | 8884cf1 | 2018-08-13 04:33:16 -0700 | [diff] [blame] | 474 | test_expect_success 'changed message' ' |
| 475 | git range-diff --no-color topic...changed-message >actual && |
Denton Liu | 75c5aa0 | 2019-11-20 13:18:38 -0800 | [diff] [blame] | 476 | sed s/Z/\ /g >expect <<-EOF && |
brian m. carlson | b561edd | 2019-08-18 19:16:34 +0000 | [diff] [blame] | 477 | 1: $(test_oid t1) = 1: $(test_oid m1) s/5/A/ |
| 478 | 2: $(test_oid t2) ! 2: $(test_oid m2) s/4/A/ |
Thomas Gummerer | 499352c | 2019-07-11 17:08:51 +0100 | [diff] [blame] | 479 | @@ Metadata |
| 480 | Z ## Commit message ## |
Thomas Rast | 8884cf1 | 2018-08-13 04:33:16 -0700 | [diff] [blame] | 481 | Z s/4/A/ |
| 482 | Z |
| 483 | + Also a silly comment here! |
| 484 | + |
Thomas Gummerer | b66885a | 2019-07-11 17:08:49 +0100 | [diff] [blame] | 485 | Z ## file ## |
| 486 | Z@@ |
| 487 | Z 1 |
brian m. carlson | b561edd | 2019-08-18 19:16:34 +0000 | [diff] [blame] | 488 | 3: $(test_oid t3) = 3: $(test_oid m3) s/11/B/ |
| 489 | 4: $(test_oid t4) = 4: $(test_oid m4) s/12/B/ |
Thomas Rast | 8884cf1 | 2018-08-13 04:33:16 -0700 | [diff] [blame] | 490 | EOF |
Denton Liu | 75c5aa0 | 2019-11-20 13:18:38 -0800 | [diff] [blame] | 491 | test_cmp expect actual |
Thomas Rast | 8884cf1 | 2018-08-13 04:33:16 -0700 | [diff] [blame] | 492 | ' |
| 493 | |
Stefan Beller | c5e64ca | 2018-08-13 18:41:16 -0700 | [diff] [blame] | 494 | test_expect_success 'dual-coloring' ' |
brian m. carlson | b561edd | 2019-08-18 19:16:34 +0000 | [diff] [blame] | 495 | sed -e "s|^:||" >expect <<-EOF && |
| 496 | :<YELLOW>1: $(test_oid c1) = 1: $(test_oid m1) s/5/A/<RESET> |
| 497 | :<RED>2: $(test_oid c2) <RESET><YELLOW>!<RESET><GREEN> 2: $(test_oid m2)<RESET><YELLOW> s/4/A/<RESET> |
Thomas Gummerer | 499352c | 2019-07-11 17:08:51 +0100 | [diff] [blame] | 498 | : <REVERSE><CYAN>@@<RESET> <RESET>Metadata<RESET> |
| 499 | : ## Commit message ##<RESET> |
Stefan Beller | c5e64ca | 2018-08-13 18:41:16 -0700 | [diff] [blame] | 500 | : s/4/A/<RESET> |
| 501 | : <RESET> |
| 502 | : <REVERSE><GREEN>+<RESET><BOLD> Also a silly comment here!<RESET> |
Stefan Beller | 29ef759 | 2018-08-13 18:41:20 -0700 | [diff] [blame] | 503 | : <REVERSE><GREEN>+<RESET> |
Thomas Gummerer | b66885a | 2019-07-11 17:08:49 +0100 | [diff] [blame] | 504 | : ## file ##<RESET> |
| 505 | : <CYAN> @@<RESET> |
| 506 | : 1<RESET> |
brian m. carlson | b561edd | 2019-08-18 19:16:34 +0000 | [diff] [blame] | 507 | :<RED>3: $(test_oid c3) <RESET><YELLOW>!<RESET><GREEN> 3: $(test_oid m3)<RESET><YELLOW> s/11/B/<RESET> |
Thomas Gummerer | 499352c | 2019-07-11 17:08:51 +0100 | [diff] [blame] | 508 | : <REVERSE><CYAN>@@<RESET> <RESET>file: A<RESET> |
Stefan Beller | c5e64ca | 2018-08-13 18:41:16 -0700 | [diff] [blame] | 509 | : 9<RESET> |
| 510 | : 10<RESET> |
| 511 | : <RED> -11<RESET> |
| 512 | : <REVERSE><RED>-<RESET><FAINT;GREEN>+BB<RESET> |
| 513 | : <REVERSE><GREEN>+<RESET><BOLD;GREEN>+B<RESET> |
| 514 | : 12<RESET> |
| 515 | : 13<RESET> |
| 516 | : 14<RESET> |
brian m. carlson | b561edd | 2019-08-18 19:16:34 +0000 | [diff] [blame] | 517 | :<RED>4: $(test_oid c4) <RESET><YELLOW>!<RESET><GREEN> 4: $(test_oid m4)<RESET><YELLOW> s/12/B/<RESET> |
Thomas Gummerer | 499352c | 2019-07-11 17:08:51 +0100 | [diff] [blame] | 518 | : <REVERSE><CYAN>@@<RESET> <RESET>file<RESET> |
Thomas Gummerer | 444e096 | 2019-07-11 17:08:50 +0100 | [diff] [blame] | 519 | : <CYAN> @@ file: A<RESET> |
Stefan Beller | c5e64ca | 2018-08-13 18:41:16 -0700 | [diff] [blame] | 520 | : 9<RESET> |
| 521 | : 10<RESET> |
| 522 | : <REVERSE><RED>-<RESET><FAINT> BB<RESET> |
| 523 | : <REVERSE><GREEN>+<RESET><BOLD> B<RESET> |
| 524 | : <RED> -12<RESET> |
| 525 | : <GREEN> +B<RESET> |
| 526 | : 13<RESET> |
| 527 | EOF |
| 528 | git range-diff changed...changed-message --color --dual-color >actual.raw && |
| 529 | test_decode_color >actual <actual.raw && |
| 530 | test_cmp expect actual |
| 531 | ' |
| 532 | |
Johannes Schindelin | d6c6b10 | 2020-11-18 23:44:23 +0000 | [diff] [blame] | 533 | for prev in topic main..topic |
Eric Sunshine | 31e2617 | 2018-07-22 05:57:13 -0400 | [diff] [blame] | 534 | do |
| 535 | test_expect_success "format-patch --range-diff=$prev" ' |
Junio C Hamano | 6caa96c | 2024-08-06 10:04:13 -0700 | [diff] [blame] | 536 | test_when_finished "rm -f 000?-*" && |
Martin Ã…gren | ac0edf1 | 2018-12-03 16:21:31 -0500 | [diff] [blame] | 537 | git format-patch --cover-letter --range-diff=$prev \ |
Johannes Schindelin | d6c6b10 | 2020-11-18 23:44:23 +0000 | [diff] [blame] | 538 | main..unmodified >actual && |
Martin Ã…gren | ac0edf1 | 2018-12-03 16:21:31 -0500 | [diff] [blame] | 539 | test_line_count = 5 actual && |
Junio C Hamano | 6789275 | 2023-10-31 14:23:30 +0900 | [diff] [blame] | 540 | test_grep "^Range-diff:$" 0000-* && |
Martin Ã…gren | ac0edf1 | 2018-12-03 16:21:31 -0500 | [diff] [blame] | 541 | grep "= 1: .* s/5/A" 0000-* && |
| 542 | grep "= 2: .* s/4/A" 0000-* && |
| 543 | grep "= 3: .* s/11/B" 0000-* && |
| 544 | grep "= 4: .* s/12/B" 0000-* |
Eric Sunshine | 31e2617 | 2018-07-22 05:57:13 -0400 | [diff] [blame] | 545 | ' |
| 546 | done |
| 547 | |
Rubén Justo | f96c385 | 2024-06-07 22:55:21 +0200 | [diff] [blame] | 548 | test_expect_success "--range-diff implies --cover-letter for multi-patch series" ' |
| 549 | test_when_finished "rm -f v2-000?-*" && |
| 550 | git format-patch -v2 --range-diff=topic main..unmodified && |
| 551 | test_grep "^Range-diff against v1:$" v2-0000-cover-letter.patch |
| 552 | ' |
| 553 | |
| 554 | test_expect_success "explicit --no-cover-letter defeats implied --cover-letter" ' |
| 555 | test_when_finished "rm -f v2-000?-*" && |
| 556 | test_must_fail git format-patch --no-cover-letter \ |
| 557 | -v2 --range-diff=topic main..unmodified && |
| 558 | test_must_fail git -c format.coverLetter=no format-patch \ |
| 559 | -v2 --range-diff=topic main..unmodified |
| 560 | ' |
| 561 | |
Derrick Stolee | cdc067c | 2018-09-12 07:31:03 -0700 | [diff] [blame] | 562 | test_expect_success 'format-patch --range-diff as commentary' ' |
Junio C Hamano | 6caa96c | 2024-08-06 10:04:13 -0700 | [diff] [blame] | 563 | test_when_finished "rm -f 0001-*" && |
Martin Ã…gren | ac0edf1 | 2018-12-03 16:21:31 -0500 | [diff] [blame] | 564 | git format-patch --range-diff=HEAD~1 HEAD~1 >actual && |
Martin Ã…gren | ac0edf1 | 2018-12-03 16:21:31 -0500 | [diff] [blame] | 565 | test_line_count = 1 actual && |
Junio C Hamano | 6789275 | 2023-10-31 14:23:30 +0900 | [diff] [blame] | 566 | test_grep "^Range-diff:$" 0001-* && |
Martin Ã…gren | ac0edf1 | 2018-12-03 16:21:31 -0500 | [diff] [blame] | 567 | grep "> 1: .* new message" 0001-* |
Derrick Stolee | cdc067c | 2018-09-12 07:31:03 -0700 | [diff] [blame] | 568 | ' |
| 569 | |
ZheNing Hu | db91988 | 2021-03-23 11:12:25 +0000 | [diff] [blame] | 570 | test_expect_success 'format-patch --range-diff reroll-count with a non-integer' ' |
Junio C Hamano | 6caa96c | 2024-08-06 10:04:13 -0700 | [diff] [blame] | 571 | test_when_finished "rm -f v2.9-0001-*" && |
ZheNing Hu | db91988 | 2021-03-23 11:12:25 +0000 | [diff] [blame] | 572 | git format-patch --range-diff=HEAD~1 -v2.9 HEAD~1 >actual && |
ZheNing Hu | db91988 | 2021-03-23 11:12:25 +0000 | [diff] [blame] | 573 | test_line_count = 1 actual && |
Junio C Hamano | 6789275 | 2023-10-31 14:23:30 +0900 | [diff] [blame] | 574 | test_grep "^Range-diff:$" v2.9-0001-* && |
ZheNing Hu | db91988 | 2021-03-23 11:12:25 +0000 | [diff] [blame] | 575 | grep "> 1: .* new message" v2.9-0001-* |
| 576 | ' |
| 577 | |
| 578 | test_expect_success 'format-patch --range-diff reroll-count with a integer' ' |
Junio C Hamano | 6caa96c | 2024-08-06 10:04:13 -0700 | [diff] [blame] | 579 | test_when_finished "rm -f v2-0001-*" && |
ZheNing Hu | db91988 | 2021-03-23 11:12:25 +0000 | [diff] [blame] | 580 | git format-patch --range-diff=HEAD~1 -v2 HEAD~1 >actual && |
ZheNing Hu | db91988 | 2021-03-23 11:12:25 +0000 | [diff] [blame] | 581 | test_line_count = 1 actual && |
Junio C Hamano | 6789275 | 2023-10-31 14:23:30 +0900 | [diff] [blame] | 582 | test_grep "^Range-diff ..* v1:$" v2-0001-* && |
ZheNing Hu | db91988 | 2021-03-23 11:12:25 +0000 | [diff] [blame] | 583 | grep "> 1: .* new message" v2-0001-* |
| 584 | ' |
| 585 | |
| 586 | test_expect_success 'format-patch --range-diff with v0' ' |
Junio C Hamano | 6caa96c | 2024-08-06 10:04:13 -0700 | [diff] [blame] | 587 | test_when_finished "rm -f v0-0001-*" && |
ZheNing Hu | db91988 | 2021-03-23 11:12:25 +0000 | [diff] [blame] | 588 | git format-patch --range-diff=HEAD~1 -v0 HEAD~1 >actual && |
ZheNing Hu | db91988 | 2021-03-23 11:12:25 +0000 | [diff] [blame] | 589 | test_line_count = 1 actual && |
Junio C Hamano | 6789275 | 2023-10-31 14:23:30 +0900 | [diff] [blame] | 590 | test_grep "^Range-diff:$" v0-0001-* && |
ZheNing Hu | db91988 | 2021-03-23 11:12:25 +0000 | [diff] [blame] | 591 | grep "> 1: .* new message" v0-0001-* |
| 592 | ' |
| 593 | |
Johannes Schindelin | 937b76e | 2019-10-02 14:10:47 -0700 | [diff] [blame] | 594 | test_expect_success 'range-diff overrides diff.noprefix internally' ' |
| 595 | git -c diff.noprefix=true range-diff HEAD^... |
| 596 | ' |
| 597 | |
Vasil Dimov | 8cf5156 | 2020-04-15 20:32:24 +0000 | [diff] [blame] | 598 | test_expect_success 'basic with modified format.pretty with suffix' ' |
| 599 | git -c format.pretty="format:commit %H%d%n" range-diff \ |
Johannes Schindelin | d6c6b10 | 2020-11-18 23:44:23 +0000 | [diff] [blame] | 600 | main..topic main..unmodified |
Vasil Dimov | 8cf5156 | 2020-04-15 20:32:24 +0000 | [diff] [blame] | 601 | ' |
| 602 | |
| 603 | test_expect_success 'basic with modified format.pretty without "commit "' ' |
| 604 | git -c format.pretty="format:%H%n" range-diff \ |
Johannes Schindelin | d6c6b10 | 2020-11-18 23:44:23 +0000 | [diff] [blame] | 605 | main..topic main..unmodified |
Vasil Dimov | 8cf5156 | 2020-04-15 20:32:24 +0000 | [diff] [blame] | 606 | ' |
| 607 | |
Denton Liu | 3bdbdfb | 2019-11-20 13:18:41 -0800 | [diff] [blame] | 608 | test_expect_success 'range-diff compares notes by default' ' |
Junio C Hamano | 6caa96c | 2024-08-06 10:04:13 -0700 | [diff] [blame] | 609 | test_when_finished "git notes remove topic unmodified || :" && |
Denton Liu | 3bdbdfb | 2019-11-20 13:18:41 -0800 | [diff] [blame] | 610 | git notes add -m "topic note" topic && |
| 611 | git notes add -m "unmodified note" unmodified && |
Johannes Schindelin | d6c6b10 | 2020-11-18 23:44:23 +0000 | [diff] [blame] | 612 | git range-diff --no-color main..topic main..unmodified \ |
Denton Liu | 3bdbdfb | 2019-11-20 13:18:41 -0800 | [diff] [blame] | 613 | >actual && |
| 614 | sed s/Z/\ /g >expect <<-EOF && |
| 615 | 1: $(test_oid t1) = 1: $(test_oid u1) s/5/A/ |
| 616 | 2: $(test_oid t2) = 2: $(test_oid u2) s/4/A/ |
| 617 | 3: $(test_oid t3) = 3: $(test_oid u3) s/11/B/ |
| 618 | 4: $(test_oid t4) ! 4: $(test_oid u4) s/12/B/ |
Denton Liu | 9f726e1 | 2019-11-20 13:18:43 -0800 | [diff] [blame] | 619 | @@ Commit message |
Denton Liu | 3bdbdfb | 2019-11-20 13:18:41 -0800 | [diff] [blame] | 620 | Z |
Denton Liu | 9f726e1 | 2019-11-20 13:18:43 -0800 | [diff] [blame] | 621 | Z |
| 622 | Z ## Notes ## |
Denton Liu | 3bdbdfb | 2019-11-20 13:18:41 -0800 | [diff] [blame] | 623 | - topic note |
| 624 | + unmodified note |
| 625 | Z |
| 626 | Z ## file ## |
| 627 | Z@@ file: A |
| 628 | EOF |
| 629 | test_cmp expect actual |
| 630 | ' |
| 631 | |
Denton Liu | bd36191 | 2019-11-20 13:18:45 -0800 | [diff] [blame] | 632 | test_expect_success 'range-diff with --no-notes' ' |
Junio C Hamano | 6caa96c | 2024-08-06 10:04:13 -0700 | [diff] [blame] | 633 | test_when_finished "git notes remove topic unmodified || :" && |
Denton Liu | bd36191 | 2019-11-20 13:18:45 -0800 | [diff] [blame] | 634 | git notes add -m "topic note" topic && |
| 635 | git notes add -m "unmodified note" unmodified && |
Johannes Schindelin | d6c6b10 | 2020-11-18 23:44:23 +0000 | [diff] [blame] | 636 | git range-diff --no-color --no-notes main..topic main..unmodified \ |
Denton Liu | bd36191 | 2019-11-20 13:18:45 -0800 | [diff] [blame] | 637 | >actual && |
| 638 | cat >expect <<-EOF && |
| 639 | 1: $(test_oid t1) = 1: $(test_oid u1) s/5/A/ |
| 640 | 2: $(test_oid t2) = 2: $(test_oid u2) s/4/A/ |
| 641 | 3: $(test_oid t3) = 3: $(test_oid u3) s/11/B/ |
| 642 | 4: $(test_oid t4) = 4: $(test_oid u4) s/12/B/ |
| 643 | EOF |
| 644 | test_cmp expect actual |
| 645 | ' |
| 646 | |
| 647 | test_expect_success 'range-diff with multiple --notes' ' |
Junio C Hamano | 6caa96c | 2024-08-06 10:04:13 -0700 | [diff] [blame] | 648 | test_when_finished "git notes --ref=note1 remove topic unmodified || :" && |
Denton Liu | bd36191 | 2019-11-20 13:18:45 -0800 | [diff] [blame] | 649 | git notes --ref=note1 add -m "topic note1" topic && |
| 650 | git notes --ref=note1 add -m "unmodified note1" unmodified && |
Junio C Hamano | 6caa96c | 2024-08-06 10:04:13 -0700 | [diff] [blame] | 651 | test_when_finished "git notes --ref=note2 remove topic unmodified || :" && |
Denton Liu | bd36191 | 2019-11-20 13:18:45 -0800 | [diff] [blame] | 652 | git notes --ref=note2 add -m "topic note2" topic && |
| 653 | git notes --ref=note2 add -m "unmodified note2" unmodified && |
Johannes Schindelin | d6c6b10 | 2020-11-18 23:44:23 +0000 | [diff] [blame] | 654 | git range-diff --no-color --notes=note1 --notes=note2 main..topic main..unmodified \ |
Denton Liu | bd36191 | 2019-11-20 13:18:45 -0800 | [diff] [blame] | 655 | >actual && |
| 656 | sed s/Z/\ /g >expect <<-EOF && |
| 657 | 1: $(test_oid t1) = 1: $(test_oid u1) s/5/A/ |
| 658 | 2: $(test_oid t2) = 2: $(test_oid u2) s/4/A/ |
| 659 | 3: $(test_oid t3) = 3: $(test_oid u3) s/11/B/ |
| 660 | 4: $(test_oid t4) ! 4: $(test_oid u4) s/12/B/ |
| 661 | @@ Commit message |
| 662 | Z |
| 663 | Z |
| 664 | Z ## Notes (note1) ## |
| 665 | - topic note1 |
| 666 | + unmodified note1 |
| 667 | Z |
| 668 | Z |
| 669 | Z ## Notes (note2) ## |
| 670 | - topic note2 |
| 671 | + unmodified note2 |
| 672 | Z |
| 673 | Z ## file ## |
| 674 | Z@@ file: A |
| 675 | EOF |
| 676 | test_cmp expect actual |
| 677 | ' |
| 678 | |
Kristoffer Haugsbakk | 2e0d30d | 2023-09-19 22:26:50 +0200 | [diff] [blame] | 679 | # `range-diff` should act like `log` with regards to notes |
| 680 | test_expect_success 'range-diff with --notes=custom does not show default notes' ' |
Junio C Hamano | 6caa96c | 2024-08-06 10:04:13 -0700 | [diff] [blame] | 681 | test_when_finished "git notes remove topic unmodified || :" && |
Kristoffer Haugsbakk | 2e0d30d | 2023-09-19 22:26:50 +0200 | [diff] [blame] | 682 | git notes add -m "topic note" topic && |
| 683 | git notes add -m "unmodified note" unmodified && |
Junio C Hamano | 6caa96c | 2024-08-06 10:04:13 -0700 | [diff] [blame] | 684 | test_when_finished "git notes --ref=custom remove topic unmodified || :" && |
Kristoffer Haugsbakk | 2e0d30d | 2023-09-19 22:26:50 +0200 | [diff] [blame] | 685 | git notes --ref=custom add -m "topic note" topic && |
| 686 | git notes --ref=custom add -m "unmodified note" unmodified && |
Kristoffer Haugsbakk | 2e0d30d | 2023-09-19 22:26:50 +0200 | [diff] [blame] | 687 | git range-diff --notes=custom main..topic main..unmodified \ |
| 688 | >actual && |
| 689 | ! grep "## Notes ##" actual && |
| 690 | grep "## Notes (custom) ##" actual |
| 691 | ' |
| 692 | |
Denton Liu | 5b583e6 | 2019-11-20 13:18:47 -0800 | [diff] [blame] | 693 | test_expect_success 'format-patch --range-diff does not compare notes by default' ' |
Junio C Hamano | 6caa96c | 2024-08-06 10:04:13 -0700 | [diff] [blame] | 694 | test_when_finished "git notes remove topic unmodified || :" && |
Denton Liu | 3bdbdfb | 2019-11-20 13:18:41 -0800 | [diff] [blame] | 695 | git notes add -m "topic note" topic && |
| 696 | git notes add -m "unmodified note" unmodified && |
Junio C Hamano | 6caa96c | 2024-08-06 10:04:13 -0700 | [diff] [blame] | 697 | test_when_finished "rm -f 000?-*" && |
Denton Liu | 3bdbdfb | 2019-11-20 13:18:41 -0800 | [diff] [blame] | 698 | git format-patch --cover-letter --range-diff=$prev \ |
Johannes Schindelin | d6c6b10 | 2020-11-18 23:44:23 +0000 | [diff] [blame] | 699 | main..unmodified >actual && |
Denton Liu | 3bdbdfb | 2019-11-20 13:18:41 -0800 | [diff] [blame] | 700 | test_line_count = 5 actual && |
Junio C Hamano | 6789275 | 2023-10-31 14:23:30 +0900 | [diff] [blame] | 701 | test_grep "^Range-diff:$" 0000-* && |
Denton Liu | 3bdbdfb | 2019-11-20 13:18:41 -0800 | [diff] [blame] | 702 | grep "= 1: .* s/5/A" 0000-* && |
| 703 | grep "= 2: .* s/4/A" 0000-* && |
| 704 | grep "= 3: .* s/11/B" 0000-* && |
Denton Liu | 5b583e6 | 2019-11-20 13:18:47 -0800 | [diff] [blame] | 705 | grep "= 4: .* s/12/B" 0000-* && |
| 706 | ! grep "Notes" 0000-* && |
| 707 | ! grep "note" 0000-* |
| 708 | ' |
| 709 | |
Kristoffer Haugsbakk | 2e0d30d | 2023-09-19 22:26:50 +0200 | [diff] [blame] | 710 | test_expect_success 'format-patch --notes=custom --range-diff only compares custom notes' ' |
Junio C Hamano | 6caa96c | 2024-08-06 10:04:13 -0700 | [diff] [blame] | 711 | test_when_finished "git notes remove topic unmodified || :" && |
Kristoffer Haugsbakk | 2e0d30d | 2023-09-19 22:26:50 +0200 | [diff] [blame] | 712 | git notes add -m "topic note" topic && |
Kristoffer Haugsbakk | 2e0d30d | 2023-09-19 22:26:50 +0200 | [diff] [blame] | 713 | git notes add -m "unmodified note" unmodified && |
Junio C Hamano | 6caa96c | 2024-08-06 10:04:13 -0700 | [diff] [blame] | 714 | test_when_finished "git notes --ref=custom remove topic unmodified || :" && |
| 715 | git notes --ref=custom add -m "topic note (custom)" topic && |
Kristoffer Haugsbakk | 2e0d30d | 2023-09-19 22:26:50 +0200 | [diff] [blame] | 716 | git notes --ref=custom add -m "unmodified note (custom)" unmodified && |
Junio C Hamano | 6caa96c | 2024-08-06 10:04:13 -0700 | [diff] [blame] | 717 | test_when_finished "rm -f 000?-*" && |
Kristoffer Haugsbakk | 2e0d30d | 2023-09-19 22:26:50 +0200 | [diff] [blame] | 718 | git format-patch --notes=custom --cover-letter --range-diff=$prev \ |
| 719 | main..unmodified >actual && |
Kristoffer Haugsbakk | 2e0d30d | 2023-09-19 22:26:50 +0200 | [diff] [blame] | 720 | grep "## Notes (custom) ##" 0000-* && |
| 721 | ! grep "## Notes ##" 0000-* |
| 722 | ' |
| 723 | |
Denton Liu | 5b583e6 | 2019-11-20 13:18:47 -0800 | [diff] [blame] | 724 | test_expect_success 'format-patch --range-diff with --no-notes' ' |
Junio C Hamano | 6caa96c | 2024-08-06 10:04:13 -0700 | [diff] [blame] | 725 | test_when_finished "git notes remove topic unmodified || :" && |
Denton Liu | 5b583e6 | 2019-11-20 13:18:47 -0800 | [diff] [blame] | 726 | git notes add -m "topic note" topic && |
| 727 | git notes add -m "unmodified note" unmodified && |
Junio C Hamano | 6caa96c | 2024-08-06 10:04:13 -0700 | [diff] [blame] | 728 | test_when_finished "rm -f 000?-*" && |
Denton Liu | 5b583e6 | 2019-11-20 13:18:47 -0800 | [diff] [blame] | 729 | git format-patch --no-notes --cover-letter --range-diff=$prev \ |
Johannes Schindelin | d6c6b10 | 2020-11-18 23:44:23 +0000 | [diff] [blame] | 730 | main..unmodified >actual && |
Denton Liu | 5b583e6 | 2019-11-20 13:18:47 -0800 | [diff] [blame] | 731 | test_line_count = 5 actual && |
Junio C Hamano | 6789275 | 2023-10-31 14:23:30 +0900 | [diff] [blame] | 732 | test_grep "^Range-diff:$" 0000-* && |
Denton Liu | 5b583e6 | 2019-11-20 13:18:47 -0800 | [diff] [blame] | 733 | grep "= 1: .* s/5/A" 0000-* && |
| 734 | grep "= 2: .* s/4/A" 0000-* && |
| 735 | grep "= 3: .* s/11/B" 0000-* && |
| 736 | grep "= 4: .* s/12/B" 0000-* && |
| 737 | ! grep "Notes" 0000-* && |
| 738 | ! grep "note" 0000-* |
| 739 | ' |
| 740 | |
| 741 | test_expect_success 'format-patch --range-diff with --notes' ' |
Junio C Hamano | 6caa96c | 2024-08-06 10:04:13 -0700 | [diff] [blame] | 742 | test_when_finished "git notes remove topic unmodified || :" && |
Denton Liu | 5b583e6 | 2019-11-20 13:18:47 -0800 | [diff] [blame] | 743 | git notes add -m "topic note" topic && |
| 744 | git notes add -m "unmodified note" unmodified && |
Junio C Hamano | 6caa96c | 2024-08-06 10:04:13 -0700 | [diff] [blame] | 745 | test_when_finished "rm -f 000?-*" && |
Denton Liu | 5b583e6 | 2019-11-20 13:18:47 -0800 | [diff] [blame] | 746 | git format-patch --notes --cover-letter --range-diff=$prev \ |
Johannes Schindelin | d6c6b10 | 2020-11-18 23:44:23 +0000 | [diff] [blame] | 747 | main..unmodified >actual && |
Denton Liu | 5b583e6 | 2019-11-20 13:18:47 -0800 | [diff] [blame] | 748 | test_line_count = 5 actual && |
Junio C Hamano | 6789275 | 2023-10-31 14:23:30 +0900 | [diff] [blame] | 749 | test_grep "^Range-diff:$" 0000-* && |
Denton Liu | 5b583e6 | 2019-11-20 13:18:47 -0800 | [diff] [blame] | 750 | grep "= 1: .* s/5/A" 0000-* && |
| 751 | grep "= 2: .* s/4/A" 0000-* && |
| 752 | grep "= 3: .* s/11/B" 0000-* && |
| 753 | grep "! 4: .* s/12/B" 0000-* && |
| 754 | sed s/Z/\ /g >expect <<-EOF && |
| 755 | @@ Commit message |
| 756 | Z |
| 757 | Z |
| 758 | Z ## Notes ## |
| 759 | - topic note |
| 760 | + unmodified note |
| 761 | Z |
| 762 | Z ## file ## |
| 763 | Z@@ file: A |
| 764 | EOF |
| 765 | sed "/@@ Commit message/,/@@ file: A/!d" 0000-* >actual && |
| 766 | test_cmp expect actual |
| 767 | ' |
| 768 | |
Denton Liu | 828765d | 2019-12-06 12:16:22 -0800 | [diff] [blame] | 769 | test_expect_success 'format-patch --range-diff with format.notes config' ' |
Junio C Hamano | 6caa96c | 2024-08-06 10:04:13 -0700 | [diff] [blame] | 770 | test_when_finished "git notes remove topic unmodified || :" && |
Denton Liu | 5b583e6 | 2019-11-20 13:18:47 -0800 | [diff] [blame] | 771 | git notes add -m "topic note" topic && |
| 772 | git notes add -m "unmodified note" unmodified && |
Denton Liu | 5b583e6 | 2019-11-20 13:18:47 -0800 | [diff] [blame] | 773 | test_config format.notes true && |
Junio C Hamano | 6caa96c | 2024-08-06 10:04:13 -0700 | [diff] [blame] | 774 | test_when_finished "rm -f 000?-*" && |
Denton Liu | 5b583e6 | 2019-11-20 13:18:47 -0800 | [diff] [blame] | 775 | git format-patch --cover-letter --range-diff=$prev \ |
Johannes Schindelin | d6c6b10 | 2020-11-18 23:44:23 +0000 | [diff] [blame] | 776 | main..unmodified >actual && |
Denton Liu | 5b583e6 | 2019-11-20 13:18:47 -0800 | [diff] [blame] | 777 | test_line_count = 5 actual && |
Junio C Hamano | 6789275 | 2023-10-31 14:23:30 +0900 | [diff] [blame] | 778 | test_grep "^Range-diff:$" 0000-* && |
Denton Liu | 5b583e6 | 2019-11-20 13:18:47 -0800 | [diff] [blame] | 779 | grep "= 1: .* s/5/A" 0000-* && |
| 780 | grep "= 2: .* s/4/A" 0000-* && |
| 781 | grep "= 3: .* s/11/B" 0000-* && |
Denton Liu | 3bdbdfb | 2019-11-20 13:18:41 -0800 | [diff] [blame] | 782 | grep "! 4: .* s/12/B" 0000-* && |
| 783 | sed s/Z/\ /g >expect <<-EOF && |
Denton Liu | 9f726e1 | 2019-11-20 13:18:43 -0800 | [diff] [blame] | 784 | @@ Commit message |
Denton Liu | 3bdbdfb | 2019-11-20 13:18:41 -0800 | [diff] [blame] | 785 | Z |
Denton Liu | 9f726e1 | 2019-11-20 13:18:43 -0800 | [diff] [blame] | 786 | Z |
| 787 | Z ## Notes ## |
Denton Liu | 3bdbdfb | 2019-11-20 13:18:41 -0800 | [diff] [blame] | 788 | - topic note |
| 789 | + unmodified note |
| 790 | Z |
| 791 | Z ## file ## |
| 792 | Z@@ file: A |
| 793 | EOF |
Denton Liu | 9f726e1 | 2019-11-20 13:18:43 -0800 | [diff] [blame] | 794 | sed "/@@ Commit message/,/@@ file: A/!d" 0000-* >actual && |
Denton Liu | 3bdbdfb | 2019-11-20 13:18:41 -0800 | [diff] [blame] | 795 | test_cmp expect actual |
| 796 | ' |
| 797 | |
Denton Liu | 5b583e6 | 2019-11-20 13:18:47 -0800 | [diff] [blame] | 798 | test_expect_success 'format-patch --range-diff with multiple notes' ' |
Junio C Hamano | 6caa96c | 2024-08-06 10:04:13 -0700 | [diff] [blame] | 799 | test_when_finished "git notes --ref=note1 remove topic unmodified || :" && |
Denton Liu | 5b583e6 | 2019-11-20 13:18:47 -0800 | [diff] [blame] | 800 | git notes --ref=note1 add -m "topic note1" topic && |
| 801 | git notes --ref=note1 add -m "unmodified note1" unmodified && |
Junio C Hamano | 6caa96c | 2024-08-06 10:04:13 -0700 | [diff] [blame] | 802 | test_when_finished "git notes --ref=note2 remove topic unmodified || :" && |
Denton Liu | 5b583e6 | 2019-11-20 13:18:47 -0800 | [diff] [blame] | 803 | git notes --ref=note2 add -m "topic note2" topic && |
| 804 | git notes --ref=note2 add -m "unmodified note2" unmodified && |
Junio C Hamano | 6caa96c | 2024-08-06 10:04:13 -0700 | [diff] [blame] | 805 | test_when_finished "rm -f 000?-*" && |
Denton Liu | 5b583e6 | 2019-11-20 13:18:47 -0800 | [diff] [blame] | 806 | git format-patch --notes=note1 --notes=note2 --cover-letter --range-diff=$prev \ |
Johannes Schindelin | d6c6b10 | 2020-11-18 23:44:23 +0000 | [diff] [blame] | 807 | main..unmodified >actual && |
Denton Liu | 5b583e6 | 2019-11-20 13:18:47 -0800 | [diff] [blame] | 808 | test_line_count = 5 actual && |
Junio C Hamano | 6789275 | 2023-10-31 14:23:30 +0900 | [diff] [blame] | 809 | test_grep "^Range-diff:$" 0000-* && |
Denton Liu | 5b583e6 | 2019-11-20 13:18:47 -0800 | [diff] [blame] | 810 | grep "= 1: .* s/5/A" 0000-* && |
| 811 | grep "= 2: .* s/4/A" 0000-* && |
| 812 | grep "= 3: .* s/11/B" 0000-* && |
| 813 | grep "! 4: .* s/12/B" 0000-* && |
| 814 | sed s/Z/\ /g >expect <<-EOF && |
| 815 | @@ Commit message |
| 816 | Z |
| 817 | Z |
| 818 | Z ## Notes (note1) ## |
| 819 | - topic note1 |
| 820 | + unmodified note1 |
| 821 | Z |
| 822 | Z |
| 823 | Z ## Notes (note2) ## |
| 824 | - topic note2 |
| 825 | + unmodified note2 |
| 826 | Z |
| 827 | Z ## file ## |
| 828 | Z@@ file: A |
| 829 | EOF |
| 830 | sed "/@@ Commit message/,/@@ file: A/!d" 0000-* >actual && |
| 831 | test_cmp expect actual |
| 832 | ' |
| 833 | |
Johannes Schindelin | 1e79f97 | 2021-02-05 14:46:13 +0000 | [diff] [blame] | 834 | test_expect_success '--left-only/--right-only' ' |
| 835 | git switch --orphan left-right && |
| 836 | test_commit first && |
| 837 | test_commit unmatched && |
| 838 | test_commit common && |
| 839 | git switch -C left-right first && |
| 840 | git cherry-pick common && |
| 841 | |
| 842 | git range-diff -s --left-only ...common >actual && |
| 843 | head_oid=$(git rev-parse --short HEAD) && |
| 844 | common_oid=$(git rev-parse --short common) && |
| 845 | echo "1: $head_oid = 2: $common_oid common" >expect && |
| 846 | test_cmp expect actual |
| 847 | ' |
| 848 | |
Johannes Schindelin | b757478 | 2022-08-26 09:39:30 +0000 | [diff] [blame] | 849 | test_expect_success 'ranges with pathspecs' ' |
| 850 | git range-diff topic...mode-only-change -- other-file >actual && |
| 851 | test_line_count = 2 actual && |
| 852 | topic_oid=$(git rev-parse --short topic) && |
| 853 | mode_change_oid=$(git rev-parse --short mode-only-change^) && |
| 854 | file_change_oid=$(git rev-parse --short mode-only-change) && |
| 855 | grep "$mode_change_oid" actual && |
| 856 | ! grep "$file_change_oid" actual && |
| 857 | ! grep "$topic_oid" actual |
| 858 | ' |
| 859 | |
Philippe Blain | 04b1f1f | 2022-06-06 20:59:13 +0000 | [diff] [blame] | 860 | test_expect_success 'submodule changes are shown irrespective of diff.submodule' ' |
| 861 | git init sub-repo && |
| 862 | test_commit -C sub-repo sub-first && |
| 863 | sub_oid1=$(git -C sub-repo rev-parse HEAD) && |
| 864 | test_commit -C sub-repo sub-second && |
| 865 | sub_oid2=$(git -C sub-repo rev-parse HEAD) && |
| 866 | test_commit -C sub-repo sub-third && |
| 867 | sub_oid3=$(git -C sub-repo rev-parse HEAD) && |
| 868 | |
| 869 | git checkout -b main-sub topic && |
Taylor Blau | 541607d | 2022-09-30 16:47:00 -0400 | [diff] [blame] | 870 | git -c protocol.file.allow=always submodule add ./sub-repo sub && |
Philippe Blain | 04b1f1f | 2022-06-06 20:59:13 +0000 | [diff] [blame] | 871 | git -C sub checkout --detach sub-first && |
| 872 | git commit -m "add sub" sub && |
| 873 | sup_oid1=$(git rev-parse --short HEAD) && |
| 874 | git checkout -b topic-sub && |
| 875 | git -C sub checkout sub-second && |
| 876 | git commit -m "change sub" sub && |
| 877 | sup_oid2=$(git rev-parse --short HEAD) && |
| 878 | git checkout -b modified-sub main-sub && |
| 879 | git -C sub checkout sub-third && |
| 880 | git commit -m "change sub" sub && |
| 881 | sup_oid3=$(git rev-parse --short HEAD) && |
| 882 | sup_oid0=$(test_oid __) && |
| 883 | |
| 884 | test_config diff.submodule log && |
| 885 | git range-diff topic topic-sub modified-sub >actual && |
| 886 | cat >expect <<-EOF && |
| 887 | 1: $sup_oid1 = 1: $sup_oid1 add sub |
| 888 | 2: $sup_oid2 < -: $sup_oid0 change sub |
| 889 | -: $sup_oid0 > 2: $sup_oid3 change sub |
| 890 | EOF |
| 891 | test_cmp expect actual && |
| 892 | test_config diff.submodule diff && |
| 893 | git range-diff topic topic-sub modified-sub >actual && |
| 894 | git range-diff --creation-factor=100 topic topic-sub modified-sub >actual && |
| 895 | cat >expect <<-EOF && |
| 896 | 1: $sup_oid1 = 1: $sup_oid1 add sub |
| 897 | 2: $sup_oid2 ! 2: $sup_oid3 change sub |
| 898 | @@ Commit message |
| 899 | ## sub ## |
| 900 | @@ |
| 901 | -Subproject commit $sub_oid1 |
| 902 | -+Subproject commit $sub_oid2 |
| 903 | ++Subproject commit $sub_oid3 |
| 904 | EOF |
| 905 | test_cmp expect actual && |
| 906 | test_config diff.submodule diff && |
| 907 | git range-diff --creation-factor=100 topic topic-sub modified-sub >actual && |
| 908 | test_cmp expect actual |
| 909 | ' |
| 910 | |
Johannes Schindelin | f804323 | 2024-12-16 14:11:21 +0000 | [diff] [blame] | 911 | test_expect_success '--diff-merges' ' |
| 912 | renamed_oid=$(git rev-parse --short renamed-file) && |
| 913 | tree=$(git merge-tree unmodified renamed-file) && |
| 914 | clean=$(git commit-tree -m merge -p unmodified -p renamed-file $tree) && |
| 915 | clean_oid=$(git rev-parse --short $clean) && |
| 916 | conflict=$(git commit-tree -m merge -p unmodified -p renamed-file^ $tree) && |
| 917 | conflict_oid=$(git rev-parse --short $conflict) && |
| 918 | |
| 919 | git range-diff --diff-merges=1 $clean...$conflict >actual && |
| 920 | cat >expect <<-EOF && |
| 921 | 1: $renamed_oid < -: ------- s/12/B/ |
| 922 | 2: $clean_oid = 1: $conflict_oid merge |
| 923 | EOF |
| 924 | test_cmp expect actual |
| 925 | ' |
| 926 | |
Thomas Rast | 8884cf1 | 2018-08-13 04:33:16 -0700 | [diff] [blame] | 927 | test_done |