@@ -160,6 +160,14 @@ test_expect_success 'revert works (commit)' '
160
160
grep "unchanged *+3/-0 file" output
161
161
'
162
162
163
+ test_expect_success ' reject multi-key input' '
164
+ saved=$(git hash-object -w file) &&
165
+ test_when_finished "git cat-file blob $saved >file" &&
166
+ echo an extra line >>file &&
167
+ test_write_lines aa | git add -p >actual &&
168
+ test_grep "is expected, got ${SQ}aa${SQ}" actual
169
+ '
170
+
163
171
test_expect_success ' setup expected' '
164
172
cat >expected <<-\EOF
165
173
EOF
@@ -526,7 +534,7 @@ test_expect_success 'split hunk setup' '
526
534
test_write_lines 10 15 20 21 22 23 24 30 40 50 60 >test
527
535
'
528
536
529
- test_expect_success ' goto hunk' '
537
+ test_expect_success ' goto hunk 1 with "g 1" ' '
530
538
test_when_finished "git reset" &&
531
539
tr _ " " >expect <<-EOF &&
532
540
(2/2) Stage this hunk [y,n,q,a,d,K,g,/,e,p,?]? + 1: -1,2 +1,3 +15
@@ -542,7 +550,20 @@ test_expect_success 'goto hunk' '
542
550
test_cmp expect actual.trimmed
543
551
'
544
552
545
- test_expect_success ' navigate to hunk via regex' '
553
+ test_expect_success ' goto hunk 1 with "g1"' '
554
+ test_when_finished "git reset" &&
555
+ tr _ " " >expect <<-EOF &&
556
+ _10
557
+ +15
558
+ _20
559
+ (1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,p,?]?_
560
+ EOF
561
+ test_write_lines s y g1 | git add -p >actual &&
562
+ tail -n 4 <actual >actual.trimmed &&
563
+ test_cmp expect actual.trimmed
564
+ '
565
+
566
+ test_expect_success ' navigate to hunk via regex /pattern' '
546
567
test_when_finished "git reset" &&
547
568
tr _ " " >expect <<-EOF &&
548
569
(2/2) Stage this hunk [y,n,q,a,d,K,g,/,e,p,?]? @@ -1,2 +1,3 @@
@@ -556,6 +577,19 @@ test_expect_success 'navigate to hunk via regex' '
556
577
test_cmp expect actual.trimmed
557
578
'
558
579
580
+ test_expect_success ' navigate to hunk via regex / pattern' '
581
+ test_when_finished "git reset" &&
582
+ tr _ " " >expect <<-EOF &&
583
+ _10
584
+ +15
585
+ _20
586
+ (1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,p,?]?_
587
+ EOF
588
+ test_write_lines s y / 1,2 | git add -p >actual &&
589
+ tail -n 4 <actual >actual.trimmed &&
590
+ test_cmp expect actual.trimmed
591
+ '
592
+
559
593
test_expect_success ' split hunk "add -p (edit)"' '
560
594
# Split, say Edit and do nothing. Then:
561
595
#
0 commit comments