@matheusbsbs / matheus-bagliano / commits / ace30ba813
Fork 0

In add --patch, Handle K,k,J,j slightly more gracefully.

Instead of printing the help menu, this will print "No next hunk" and then process the given hunk again. Signed-off-by: William Pursell <bill.pursell@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

William Pursell committed Nov 27, 2008 at 04:08 UTC ace30ba813ed723534c3b4d223db6eddea417de7
1 file changed +28 -15
git-add--interactive.perl
+28 -15
@@ -1039,29 +1039,42 @@ sub patch_update_file {
1039 $ix = $iy;
1040 next;
1041 }
1042 - elsif ($other =~ /K/ && $line =~ /^K/) {
1043 - $ix--;
1042 + elsif ($line =~ /^K/) {
1043 + if ($other =~ /K/) {
1044 + $ix--;
1045 + }
1046 + else {
1047 + print STDERR "No previous hunk\n";
1048 + }
1049 next;
1050 }
1046 - elsif ($other =~ /J/ && $line =~ /^J/) {
1047 - $ix++;
1051 + elsif ($line =~ /^J/) {
1052 + if ($other =~ /J/) {
1053 + $ix++;
1054 + }
1055 + else {
1056 + print STDERR "No next hunk\n";
1057 + }
1058 next;
1059 }
1050 - elsif ($other =~ /k/ && $line =~ /^k/) {
1051 - while (1) {
1052 - $ix--;
1053 - last if (!$ix ||
1054 - !defined $hunk[$ix]{USE});
1060 + elsif ($line =~ /^k/) {
1061 + if ($other =~ /k/) {
1062 + while (1) {
1063 + $ix--;
1064 + last if (!$ix ||
1065 + !defined $hunk[$ix]{USE});
1066 + }
1067 + }
1068 + else {
1069 + print STDERR "No previous hunk\n";
1070 }
1071 next;
1072 }
1058 - elsif ($other =~ /j/ && $line =~ /^j/) {
1059 - while (1) {
1060 - $ix++;
1061 - last if ($ix >= $num ||
1062 - !defined $hunk[$ix]{USE});
1073 + elsif ($line =~ /^j/) {
1074 + if ($other !~ /j/) {
1075 + print STDERR "No next hunk\n";
1076 + next;
1077 }
1064 - next;
1078 }
1079 elsif ($other =~ /s/ && $line =~ /^s/) {
1080 my @split = split_hunk($hunk[$ix]{TEXT}, $hunk[$ix]{DISPLAY});