@@ -48,8 +48,8 @@ test_expect_success 'unknown command' '
4848 git add -N command &&
4949 git diff command >expect &&
5050 cat >>expect <<-EOF &&
51- (1/1) Stage addition [y,n,q,a,d,e,p,P,?]? Unknown command ${SQ}W${SQ} (use ${SQ}?${SQ} for help)
52- (1/1) Stage addition [y,n,q,a,d,e,p,P,?]?$SP
51+ (1/1) Stage addition [y,n,q,a,d,e,w, p,P,?]? Unknown command ${SQ}W${SQ} (use ${SQ}?${SQ} for help)
52+ (1/1) Stage addition [y,n,q,a,d,e,w, p,P,?]?$SP
5353 EOF
5454 git add -p -- command <command >actual 2>&1 &&
5555 test_cmp expect actual
@@ -332,9 +332,9 @@ test_expect_success 'different prompts for mode change/deleted' '
332332 git -c core.filemode=true add -p >actual &&
333333 sed -n "s/^\(([0-9/]*) Stage .*?\).*/\1/p" actual >actual.filtered &&
334334 cat >expect <<-\EOF &&
335- (1/1) Stage deletion [y,n,q,a,d,p,P,?]?
336- (1/2) Stage mode change [y,n,q,a,d,k,K,j,J,g,/,p,P,?]?
337- (2/2) Stage this hunk [y,n,q,a,d,K,J,g,/,e,p,P,?]?
335+ (1/1) Stage deletion [y,n,q,a,d,w, p,P,?]?
336+ (1/2) Stage mode change [y,n,q,a,d,k,K,j,J,g,/,w, p,P,?]?
337+ (2/2) Stage this hunk [y,n,q,a,d,K,J,g,/,e,w, p,P,?]?
338338 EOF
339339 test_cmp expect actual.filtered
340340'
@@ -521,13 +521,13 @@ test_expect_success 'split hunk setup' '
521521test_expect_success ' goto hunk 1 with "g 1"' '
522522 test_when_finished "git reset" &&
523523 tr _ " " >expect <<-EOF &&
524- (2/2) Stage this hunk [y,n,q,a,d,K,J,g,/,e,p,P,?]? + 1: -1,2 +1,3 +15
524+ (2/2) Stage this hunk [y,n,q,a,d,K,J,g,/,e,w, p,P,?]? + 1: -1,2 +1,3 +15
525525 _ 2: -2,4 +3,8 +21
526526 go to which hunk? @@ -1,2 +1,3 @@
527527 _10
528528 +15
529529 _20
530- (1/2) Stage this hunk (was: y) [y,n,q,a,d,k,K,j,J,g,/,e,p,P,?]?_
530+ (1/2) Stage this hunk (was: y) [y,n,q,a,d,k,K,j,J,g,/,e,w, p,P,?]?_
531531 EOF
532532 test_write_lines s y g 1 | git add -p >actual &&
533533 tail -n 7 <actual >actual.trimmed &&
@@ -540,7 +540,7 @@ test_expect_success 'goto hunk 1 with "g1"' '
540540 _10
541541 +15
542542 _20
543- (1/2) Stage this hunk (was: y) [y,n,q,a,d,k,K,j,J,g,/,e,p,P,?]?_
543+ (1/2) Stage this hunk (was: y) [y,n,q,a,d,k,K,j,J,g,/,e,w, p,P,?]?_
544544 EOF
545545 test_write_lines s y g1 | git add -p >actual &&
546546 tail -n 4 <actual >actual.trimmed &&
@@ -550,11 +550,11 @@ test_expect_success 'goto hunk 1 with "g1"' '
550550test_expect_success ' navigate to hunk via regex /pattern' '
551551 test_when_finished "git reset" &&
552552 tr _ " " >expect <<-EOF &&
553- (2/2) Stage this hunk [y,n,q,a,d,K,J,g,/,e,p,P,?]? @@ -1,2 +1,3 @@
553+ (2/2) Stage this hunk [y,n,q,a,d,K,J,g,/,e,w, p,P,?]? @@ -1,2 +1,3 @@
554554 _10
555555 +15
556556 _20
557- (1/2) Stage this hunk (was: y) [y,n,q,a,d,k,K,j,J,g,/,e,p,P,?]?_
557+ (1/2) Stage this hunk (was: y) [y,n,q,a,d,k,K,j,J,g,/,e,w, p,P,?]?_
558558 EOF
559559 test_write_lines s y /1,2 | git add -p >actual &&
560560 tail -n 5 <actual >actual.trimmed &&
@@ -567,7 +567,7 @@ test_expect_success 'navigate to hunk via regex / pattern' '
567567 _10
568568 +15
569569 _20
570- (1/2) Stage this hunk (was: y) [y,n,q,a,d,k,K,j,J,g,/,e,p,P,?]?_
570+ (1/2) Stage this hunk (was: y) [y,n,q,a,d,k,K,j,J,g,/,e,w, p,P,?]?_
571571 EOF
572572 test_write_lines s y / 1,2 | git add -p >actual &&
573573 tail -n 4 <actual >actual.trimmed &&
@@ -579,27 +579,40 @@ test_expect_success 'print again the hunk' '
579579 tr _ " " >expect <<-EOF &&
580580 +15
581581 20
582- (1/2) Stage this hunk (was: y) [y,n,q,a,d,k,K,j,J,g,/,e,p,P,?]? @@ -1,2 +1,3 @@
582+ (1/2) Stage this hunk (was: y) [y,n,q,a,d,k,K,j,J,g,/,e,w, p,P,?]? @@ -1,2 +1,3 @@
583583 10
584584 +15
585585 20
586- (1/2) Stage this hunk (was: y) [y,n,q,a,d,k,K,j,J,g,/,e,p,P,?]?_
586+ (1/2) Stage this hunk (was: y) [y,n,q,a,d,k,K,j,J,g,/,e,w, p,P,?]?_
587587 EOF
588588 test_write_lines s y g 1 p | git add -p >actual &&
589589 tail -n 7 <actual >actual.trimmed &&
590590 test_cmp expect actual.trimmed
591591'
592592
593+ test_expect_success ' print hunk with word-diff' '
594+ head=$(git rev-parse HEAD) &&
595+ test_when_finished "git reset --hard $head && rm -f word-diff" &&
596+ git reset --hard &&
597+ test_write_lines "alpha old beta" context >word-diff &&
598+ git add word-diff &&
599+ git commit -m word-diff &&
600+ test_write_lines "alpha new beta" context >word-diff &&
601+ test_write_lines w n | git add -p word-diff >actual &&
602+ test_grep "alpha \\[-old-\\]{+new+} beta" actual &&
603+ git diff --cached --exit-code
604+ '
605+
593606test_expect_success TTY ' print again the hunk (PAGER)' '
594607 test_when_finished "git reset" &&
595608 cat >expect <<-EOF &&
596609 <GREEN>+<RESET><GREEN>15<RESET>
597610 20<RESET>
598- <BOLD;BLUE>(1/2) Stage this hunk (was: y) [y,n,q,a,d,k,K,j,J,g,/,e,p,P,?]? <RESET>PAGER <CYAN>@@ -1,2 +1,3 @@<RESET>
611+ <BOLD;BLUE>(1/2) Stage this hunk (was: y) [y,n,q,a,d,k,K,j,J,g,/,e,w, p,P,?]? <RESET>PAGER <CYAN>@@ -1,2 +1,3 @@<RESET>
599612 PAGER 10<RESET>
600613 PAGER <GREEN>+<RESET><GREEN>15<RESET>
601614 PAGER 20<RESET>
602- <BOLD;BLUE>(1/2) Stage this hunk (was: y) [y,n,q,a,d,k,K,j,J,g,/,e,p,P,?]? <RESET>
615+ <BOLD;BLUE>(1/2) Stage this hunk (was: y) [y,n,q,a,d,k,K,j,J,g,/,e,w, p,P,?]? <RESET>
603616 EOF
604617 test_write_lines s y g 1 P |
605618 (
@@ -796,21 +809,21 @@ test_expect_success 'colors can be overridden' '
796809 <BLUE>+<RESET><BLUE>new<RESET>
797810 <CYAN> more-context<RESET>
798811 <BLUE>+<RESET><BLUE>another-one<RESET>
799- <YELLOW>(1/1) Stage this hunk [y,n,q,a,d,s,e,p,P,?]? <RESET><BOLD>Split into 2 hunks.<RESET>
812+ <YELLOW>(1/1) Stage this hunk [y,n,q,a,d,s,e,w, p,P,?]? <RESET><BOLD>Split into 2 hunks.<RESET>
800813 <MAGENTA>@@ -1,3 +1,3 @@<RESET>
801814 <CYAN> context<RESET>
802815 <BOLD>-old<RESET>
803816 <BLUE>+<RESET><BLUE>new<RESET>
804817 <CYAN> more-context<RESET>
805- <YELLOW>(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,P,?]? <RESET><MAGENTA>@@ -3 +3,2 @@<RESET>
818+ <YELLOW>(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,w, p,P,?]? <RESET><MAGENTA>@@ -3 +3,2 @@<RESET>
806819 <CYAN> more-context<RESET>
807820 <BLUE>+<RESET><BLUE>another-one<RESET>
808- <YELLOW>(2/2) Stage this hunk [y,n,q,a,d,K,J,g,/,e,p,P,?]? <RESET><MAGENTA>@@ -1,3 +1,3 @@<RESET>
821+ <YELLOW>(2/2) Stage this hunk [y,n,q,a,d,K,J,g,/,e,w, p,P,?]? <RESET><MAGENTA>@@ -1,3 +1,3 @@<RESET>
809822 <CYAN> context<RESET>
810823 <BOLD>-old<RESET>
811824 <BLUE>+new<RESET>
812825 <CYAN> more-context<RESET>
813- <YELLOW>(1/2) Stage this hunk (was: y) [y,n,q,a,d,k,K,j,J,g,/,e,p,P,?]? <RESET>
826+ <YELLOW>(1/2) Stage this hunk (was: y) [y,n,q,a,d,k,K,j,J,g,/,e,w, p,P,?]? <RESET>
814827 EOF
815828 test_cmp expect actual
816829'
@@ -1424,9 +1437,9 @@ test_expect_success 'invalid option s is rejected' '
14241437 test_write_lines j s q | git add -p >out &&
14251438 sed -ne "s/ @@.*//" -e "s/ \$//" -e "/^(/p" <out >actual &&
14261439 cat >expect <<-EOF &&
1427- (1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,s,e,p,P,?]?
1428- (2/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,P,?]? Sorry, cannot split this hunk
1429- (2/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,P,?]?
1440+ (1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,s,e,w, p,P,?]?
1441+ (2/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,w, p,P,?]? Sorry, cannot split this hunk
1442+ (2/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,w, p,P,?]?
14301443 EOF
14311444 test_cmp expect actual
14321445'
0 commit comments