@@ -333,8 +333,8 @@ test_expect_success 'different prompts for mode change/deleted' '
333
333
sed -n "s/^\(([0-9/]*) Stage .*?\).*/\1/p" actual >actual.filtered &&
334
334
cat >expect <<-\EOF &&
335
335
(1/1) Stage deletion [y,n,q,a,d,p,?]?
336
- (1/2) Stage mode change [y,n,q,a,d,j,J,g,/,p,?]?
337
- (2/2) Stage this hunk [y,n,q,a,d,K,g,/,e,p,?]?
336
+ (1/2) Stage mode change [y,n,q,a,d,k,K, j,J,g,/,p,?]?
337
+ (2/2) Stage this hunk [y,n,q,a,d,K,J, g,/,e,p,?]?
338
338
EOF
339
339
test_cmp expect actual.filtered
340
340
'
@@ -521,13 +521,13 @@ test_expect_success 'split hunk setup' '
521
521
test_expect_success ' goto hunk 1 with "g 1"' '
522
522
test_when_finished "git reset" &&
523
523
tr _ " " >expect <<-EOF &&
524
- (2/2) Stage this hunk [y,n,q,a,d,K,g,/,e,p,?]? + 1: -1,2 +1,3 +15
524
+ (2/2) Stage this hunk [y,n,q,a,d,K,J, g,/,e,p,?]? + 1: -1,2 +1,3 +15
525
525
_ 2: -2,4 +3,8 +21
526
526
go to which hunk? @@ -1,2 +1,3 @@
527
527
_10
528
528
+15
529
529
_20
530
- (1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,p,?]?_
530
+ (1/2) Stage this hunk [y,n,q,a,d,k,K, j,J,g,/,e,p,?]?_
531
531
EOF
532
532
test_write_lines s y g 1 | git add -p >actual &&
533
533
tail -n 7 <actual >actual.trimmed &&
@@ -540,7 +540,7 @@ test_expect_success 'goto hunk 1 with "g1"' '
540
540
_10
541
541
+15
542
542
_20
543
- (1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,p,?]?_
543
+ (1/2) Stage this hunk [y,n,q,a,d,k,K, j,J,g,/,e,p,?]?_
544
544
EOF
545
545
test_write_lines s y g1 | git add -p >actual &&
546
546
tail -n 4 <actual >actual.trimmed &&
@@ -550,11 +550,11 @@ test_expect_success 'goto hunk 1 with "g1"' '
550
550
test_expect_success ' navigate to hunk via regex /pattern' '
551
551
test_when_finished "git reset" &&
552
552
tr _ " " >expect <<-EOF &&
553
- (2/2) Stage this hunk [y,n,q,a,d,K,g,/,e,p,?]? @@ -1,2 +1,3 @@
553
+ (2/2) Stage this hunk [y,n,q,a,d,K,J, g,/,e,p,?]? @@ -1,2 +1,3 @@
554
554
_10
555
555
+15
556
556
_20
557
- (1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,p,?]?_
557
+ (1/2) Stage this hunk [y,n,q,a,d,k,K, j,J,g,/,e,p,?]?_
558
558
EOF
559
559
test_write_lines s y /1,2 | git add -p >actual &&
560
560
tail -n 5 <actual >actual.trimmed &&
@@ -567,7 +567,7 @@ test_expect_success 'navigate to hunk via regex / pattern' '
567
567
_10
568
568
+15
569
569
_20
570
- (1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,p,?]?_
570
+ (1/2) Stage this hunk [y,n,q,a,d,k,K, j,J,g,/,e,p,?]?_
571
571
EOF
572
572
test_write_lines s y / 1,2 | git add -p >actual &&
573
573
tail -n 4 <actual >actual.trimmed &&
@@ -579,11 +579,11 @@ test_expect_success 'print again the hunk' '
579
579
tr _ " " >expect <<-EOF &&
580
580
+15
581
581
20
582
- (1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,p,?]? @@ -1,2 +1,3 @@
582
+ (1/2) Stage this hunk [y,n,q,a,d,k,K, j,J,g,/,e,p,?]? @@ -1,2 +1,3 @@
583
583
10
584
584
+15
585
585
20
586
- (1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,p,?]?_
586
+ (1/2) Stage this hunk [y,n,q,a,d,k,K, j,J,g,/,e,p,?]?_
587
587
EOF
588
588
test_write_lines s y g 1 p | git add -p >actual &&
589
589
tail -n 7 <actual >actual.trimmed &&
@@ -595,11 +595,11 @@ test_expect_success TTY 'print again the hunk (PAGER)' '
595
595
cat >expect <<-EOF &&
596
596
<GREEN>+<RESET><GREEN>15<RESET>
597
597
20<RESET>
598
- <BOLD;BLUE>(1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,p,?]? <RESET>PAGER <CYAN>@@ -1,2 +1,3 @@<RESET>
598
+ <BOLD;BLUE>(1/2) Stage this hunk [y,n,q,a,d,k,K, j,J,g,/,e,p,?]? <RESET>PAGER <CYAN>@@ -1,2 +1,3 @@<RESET>
599
599
PAGER 10<RESET>
600
600
PAGER <GREEN>+<RESET><GREEN>15<RESET>
601
601
PAGER 20<RESET>
602
- <BOLD;BLUE>(1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,p,?]? <RESET>
602
+ <BOLD;BLUE>(1/2) Stage this hunk [y,n,q,a,d,k,K, j,J,g,/,e,p,?]? <RESET>
603
603
EOF
604
604
test_write_lines s y g 1 P |
605
605
(
@@ -802,15 +802,15 @@ test_expect_success 'colors can be overridden' '
802
802
<BOLD>-old<RESET>
803
803
<BLUE>+<RESET><BLUE>new<RESET>
804
804
<CYAN> more-context<RESET>
805
- <YELLOW>(1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,p,?]? <RESET><MAGENTA>@@ -3 +3,2 @@<RESET>
805
+ <YELLOW>(1/2) Stage this hunk [y,n,q,a,d,k,K, j,J,g,/,e,p,?]? <RESET><MAGENTA>@@ -3 +3,2 @@<RESET>
806
806
<CYAN> more-context<RESET>
807
807
<BLUE>+<RESET><BLUE>another-one<RESET>
808
- <YELLOW>(2/2) Stage this hunk [y,n,q,a,d,K,g,/,e,p,?]? <RESET><MAGENTA>@@ -1,3 +1,3 @@<RESET>
808
+ <YELLOW>(2/2) Stage this hunk [y,n,q,a,d,K,J, g,/,e,p,?]? <RESET><MAGENTA>@@ -1,3 +1,3 @@<RESET>
809
809
<CYAN> context<RESET>
810
810
<BOLD>-old<RESET>
811
811
<BLUE>+new<RESET>
812
812
<CYAN> more-context<RESET>
813
- <YELLOW>(1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,p,?]? <RESET>
813
+ <YELLOW>(1/2) Stage this hunk [y,n,q,a,d,k,K, j,J,g,/,e,p,?]? <RESET>
814
814
EOF
815
815
test_cmp expect actual
816
816
'
@@ -1385,4 +1385,50 @@ test_expect_success 'splitting edited hunk' '
1385
1385
test_cmp expect actual
1386
1386
'
1387
1387
1388
+ test_expect_success ' options J, K roll over' '
1389
+ test_write_lines a b c d e f g h i >file &&
1390
+ git add file &&
1391
+ test_write_lines X b c d e f g h X >file &&
1392
+ test_write_lines J J K q | git add -p >out &&
1393
+ test_write_lines 1 2 1 2 >expect &&
1394
+ sed -n -e "s-/.*--" -e "s/^(//p" <out >actual &&
1395
+ test_cmp expect actual
1396
+ '
1397
+
1398
+ test_expect_success ' options y, n, a, d, j, k, e roll over to next undecided (1)' '
1399
+ test_write_lines a b c d e f g h i j k l m n o p q >file &&
1400
+ git add file &&
1401
+ test_write_lines X b c d e f g h X j k l m n o p X >file &&
1402
+ test_set_editor : &&
1403
+ test_write_lines g3 y g3 n g3 a g3 d g3 j g3 e k q | git add -p >out &&
1404
+ test_write_lines 1 3 1 3 1 3 1 3 1 3 1 3 1 2 >expect &&
1405
+ sed -n -e "s-/.*--" -e "s/^(//p" <out >actual &&
1406
+ test_cmp expect actual
1407
+ '
1408
+
1409
+ test_expect_success ' options y, n, a, d, j, k, e roll over to next undecided (2)' '
1410
+ test_write_lines a b c d e f g h i j k l m n o p q >file &&
1411
+ git add file &&
1412
+ test_write_lines X b c d e f g h X j k l m n o p X >file &&
1413
+ test_set_editor : &&
1414
+ test_write_lines y g3 y g3 n g3 a g3 d g3 j g3 e g1 k q | git add -p >out &&
1415
+ test_write_lines 1 2 3 2 3 2 3 2 3 2 3 2 3 2 1 2 >expect &&
1416
+ sed -n -e "s-/.*--" -e "s/^(//p" <out >actual &&
1417
+ test_cmp expect actual
1418
+ '
1419
+
1420
+ test_expect_success ' invalid option s is rejected' '
1421
+ test_write_lines a b c d e f g h i j k >file &&
1422
+ git add file &&
1423
+ test_write_lines X b X d e f g h i j X >file &&
1424
+ test_write_lines j s q | git add -p >out &&
1425
+ sed -ne "s/ @@.*//" -e "s/ \$//" -e "/^(/p" <out >actual &&
1426
+ cat >expect <<-EOF &&
1427
+ (1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,s,e,p,?]?
1428
+ (2/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,?]? Sorry, cannot split this hunk
1429
+ (2/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,?]?
1430
+ EOF
1431
+ test_cmp expect actual
1432
+ '
1433
+
1388
1434
test_done
0 commit comments