142
git diff --ignore-space-at-eol > out
143
test_expect_success 'another test, with --ignore-space-at-eol' 'test_cmp expect out'
144
145
+test_expect_success 'ignore-blank-lines: only new lines' '
146
+ test_seq 5 >x &&
147
+ git update-index x &&
148
+ test_seq 5 | sed "/3/i \\
149
+" >x &&
150
+ git diff --ignore-blank-lines >out &&
151
+ >expect &&
152
+ test_cmp out expect
153
+'
154
+
155
+test_expect_success 'ignore-blank-lines: only new lines with space' '
156
+ test_seq 5 >x &&
157
+ git update-index x &&
158
+ test_seq 5 | sed "/3/i \ " >x &&
159
+ git diff -w --ignore-blank-lines >out &&
160
+ >expect &&
161
+ test_cmp out expect
162
+'
163
+
164
+test_expect_success 'ignore-blank-lines: after change' '
165
+ cat <<-\EOF >x &&
166
+ 1
167
+ 2
168
+
169
+ 3
170
+ 4
171
+ 5
172
+
173
+ 6
174
+ 7
175
+ EOF
176
+ git update-index x &&
177
+ cat <<-\EOF >x &&
178
+ change
179
+
180
+ 1
181
+ 2
182
+ 3
183
+ 4
184
+ 5
185
+ 6
186
+
187
+ 7
188
+ EOF
189
+ git diff --inter-hunk-context=100 --ignore-blank-lines >out.tmp &&
190
+ cat <<-\EOF >expected &&
191
+ diff --git a/x b/x
192
+ --- a/x
193
+ +++ b/x
194
+ @@ -1,6 +1,7 @@
195
+ +change
196
+ +
197
+ 1
198
+ 2
199
+ -
200
+ 3
201
+ 4
202
+ 5
203
+ EOF
204
+ compare_diff_patch expected out.tmp
205
+'
206
+
207
+test_expect_success 'ignore-blank-lines: before change' '
208
+ cat <<-\EOF >x &&
209
+ 1
210
+ 2
211
+
212
+ 3
213
+ 4
214
+ 5
215
+ 6
216
+ 7
217
+ EOF
218
+ git update-index x &&
219
+ cat <<-\EOF >x &&
220
+
221
+ 1
222
+ 2
223
+ 3
224
+ 4
225
+ 5
226
+
227
+ 6
228
+ 7
229
+ change
230
+ EOF
231
+ git diff --inter-hunk-context=100 --ignore-blank-lines >out.tmp &&
232
+ cat <<-\EOF >expected &&
233
+ diff --git a/x b/x
234
+ --- a/x
235
+ +++ b/x
236
+ @@ -4,5 +4,7 @@
237
+ 3
238
+ 4
239
+ 5
240
+ +
241
+ 6
242
+ 7
243
+ +change
244
+ EOF
245
+ compare_diff_patch expected out.tmp
246
+'
247
+
248
+test_expect_success 'ignore-blank-lines: between changes' '
249
+ cat <<-\EOF >x &&
250
+ 1
251
+ 2
252
+ 3
253
+ 4
254
+ 5
255
+
256
+
257
+ 6
258
+ 7
259
+ 8
260
+ 9
261
+ 10
262
+ EOF
263
+ git update-index x &&
264
+ cat <<-\EOF >x &&
265
+ change
266
+ 1
267
+ 2
268
+
269
+ 3
270
+ 4
271
+ 5
272
+ 6
273
+ 7
274
+ 8
275
+
276
+ 9
277
+ 10
278
+ change
279
+ EOF
280
+ git diff --ignore-blank-lines >out.tmp &&
281
+ cat <<-\EOF >expected &&
282
+ diff --git a/x b/x
283
+ --- a/x
284
+ +++ b/x
285
+ @@ -1,5 +1,7 @@
286
+ +change
287
+ 1
288
+ 2
289
+ +
290
+ 3
291
+ 4
292
+ 5
293
+ @@ -8,5 +8,7 @@
294
+ 6
295
+ 7
296
+ 8
297
+ +
298
+ 9
299
+ 10
300
+ +change
301
+ EOF
302
+ compare_diff_patch expected out.tmp
303
+'
304
+
305
+test_expect_success 'ignore-blank-lines: between changes (with interhunkctx)' '
306
+ test_seq 10 >x &&
307
+ git update-index x &&
308
+ cat <<-\EOF >x &&
309
+ change
310
+ 1
311
+ 2
312
+
313
+ 3
314
+ 4
315
+ 5
316
+
317
+ 6
318
+ 7
319
+ 8
320
+ 9
321
+
322
+ 10
323
+ change
324
+ EOF
325
+ git diff --inter-hunk-context=2 --ignore-blank-lines >out.tmp &&
326
+ cat <<-\EOF >expected &&
327
+ diff --git a/x b/x
328
+ --- a/x
329
+ +++ b/x
330
+ @@ -1,10 +1,15 @@
331
+ +change
332
+ 1
333
+ 2
334
+ +
335
+ 3
336
+ 4
337
+ 5
338
+ +
339
+ 6
340
+ 7
341
+ 8
342
+ 9
343
+ +
344
+ 10
345
+ +change
346
+ EOF
347
+ compare_diff_patch expected out.tmp
348
+'
349
+
350
+test_expect_success 'ignore-blank-lines: scattered spaces' '
351
+ test_seq 10 >x &&
352
+ git update-index x &&
353
+ cat <<-\EOF >x &&
354
+ change
355
+ 1
356
+ 2
357
+ 3
358
+
359
+ 4
360
+
361
+ 5
362
+
363
+ 6
364
+
365
+
366
+ 7
367
+
368
+ 8
369
+ 9
370
+ 10
371
+ change
372
+ EOF
373
+ git diff --inter-hunk-context=4 --ignore-blank-lines >out.tmp &&
374
+ cat <<-\EOF >expected &&
375
+ diff --git a/x b/x
376
+ --- a/x
377
+ +++ b/x
378
+ @@ -1,3 +1,4 @@
379
+ +change
380
+ 1
381
+ 2
382
+ 3
383
+ @@ -8,3 +15,4 @@
384
+ 8
385
+ 9
386
+ 10
387
+ +change
388
+ EOF
389
+ compare_diff_patch expected out.tmp
390
+'
391
+
392
+test_expect_success 'ignore-blank-lines: spaces coalesce' '
393
+ test_seq 6 >x &&
394
+ git update-index x &&
395
+ cat <<-\EOF >x &&
396
+ change
397
+ 1
398
+ 2
399
+ 3
400
+
401
+ 4
402
+
403
+ 5
404
+
405
+ 6
406
+ change
407
+ EOF
408
+ git diff --inter-hunk-context=4 --ignore-blank-lines >out.tmp &&
409
+ cat <<-\EOF >expected &&
410
+ diff --git a/x b/x
411
+ --- a/x
412
+ +++ b/x
413
+ @@ -1,6 +1,11 @@
414
+ +change
415
+ 1
416
+ 2
417
+ 3
418
+ +
419
+ 4
420
+ +
421
+ 5
422
+ +
423
+ 6
424
+ +change
425
+ EOF
426
+ compare_diff_patch expected out.tmp
427
+'
428
+
429
+test_expect_success 'ignore-blank-lines: mix changes and blank lines' '
430
+ test_seq 16 >x &&
431
+ git update-index x &&
432
+ cat <<-\EOF >x &&
433
+ change
434
+ 1
435
+ 2
436
+
437
+ 3
438
+ 4
439
+ 5
440
+ change
441
+ 6
442
+ 7
443
+ 8
444
+
445
+ 9
446
+ 10
447
+ 11
448
+ change
449
+ 12
450
+ 13
451
+ 14
452
+
453
+ 15
454
+ 16
455
+ change
456
+ EOF
457
+ git diff --ignore-blank-lines >out.tmp &&
458
+ cat <<-\EOF >expected &&
459
+ diff --git a/x b/x
460
+ --- a/x
461
+ +++ b/x
462
+ @@ -1,8 +1,11 @@
463
+ +change
464
+ 1
465
+ 2
466
+ +
467
+ 3
468
+ 4
469
+ 5
470
+ +change
471
+ 6
472
+ 7
473
+ 8
474
+ @@ -9,8 +13,11 @@
475
+ 9
476
+ 10
477
+ 11
478
+ +change
479
+ 12
480
+ 13
481
+ 14
482
+ +
483
+ 15
484
+ 16
485
+ +change
486
+ EOF
487
+ compare_diff_patch expected out.tmp
488
+'
489
+
490
test_expect_success 'check mixed spaces and tabs in indent' '
491
492
# This is indented with SP HT SP.