@@ -160,6 +160,14 @@ test_expect_success 'revert works (commit)' '
160160 grep "unchanged *+3/-0 file" output
161161'
162162
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+
163171test_expect_success ' setup expected' '
164172 cat >expected <<-\EOF
165173 EOF
@@ -526,7 +534,7 @@ test_expect_success 'split hunk setup' '
526534 test_write_lines 10 15 20 21 22 23 24 30 40 50 60 >test
527535'
528536
529- test_expect_success ' goto hunk' '
537+ test_expect_success ' goto hunk 1 with "g 1" ' '
530538 test_when_finished "git reset" &&
531539 tr _ " " >expect <<-EOF &&
532540 (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' '
542550 test_cmp expect actual.trimmed
543551'
544552
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' '
546567 test_when_finished "git reset" &&
547568 tr _ " " >expect <<-EOF &&
548569 (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' '
556577 test_cmp expect actual.trimmed
557578'
558579
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+
559593test_expect_success ' split hunk "add -p (edit)"' '
560594 # Split, say Edit and do nothing. Then:
561595 #
0 commit comments