{"thread":{"id":"16484","subject":"[PATCH 2/2] In add --patch, Handle K,k,J,j slightly more gracefully.","startedAt":"2008-11-26T20:51:26Z","lastAt":"2008-11-26T21:55:47Z","messageCount":2,"participants":["William Pursell","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"96578","messageId":"492DB6CE.3010409@gmail.com","threadId":"16484","inReplyTo":null,"subject":"[PATCH 2/2] In add --patch, Handle K,k,J,j slightly more gracefully.","fromName":"William Pursell","fromEmail":"bill.pursell@gmail.com","sentAt":"2008-11-26T20:51:26Z","receivedAt":"2008-11-26T20:51:26Z","isPatch":true,"sender":{"key":"bill.pursell@gmail.com","avatar":"https://gravatar.com/avatar/3ab4313e5dfdc1fedb65206d829ba33f71f56f26e11326979d1b99d5e1c403c9?d=mp&s=160"},"body":"\n\n\nInstead of printing the help menu, this will print\n\"No next hunk\" and then process the given hunk again.\n---\n  git-add--interactive.perl |   35 +++++++++++++++++++----------------\n  1 files changed, 19 insertions(+), 16 deletions(-)\n\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex 7ad4ee0..6321bd9 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -964,29 +964,32 @@ sub patch_update_file {\n  \t\t\telsif ($line =~ m|^/(.*)|) {\n  \t\t\t\t$search_s = $1;\n  \t\t\t}\n-\t\t\telsif ($other =~ /K/ && $line =~ /^K/) {\n-\t\t\t\t$ix--;\n+\t\t\telsif ( $line =~ /^K/) {\n+\t\t\t\t$other =~ /K/ ?  $ix-- : print STDERR \"No previous hunk\\n\";\n  \t\t\t\tnext;\n  \t\t\t}\n-\t\t\telsif ($other =~ /J/ && $line =~ /^J/) {\n-\t\t\t\t$ix++;\n+\t\t\telsif ($line =~ /^J/) {\n+\t\t\t\t$other =~ /J/ ?  $ix++ : print STDERR \"No next hunk\\n\";\n  \t\t\t\tnext;\n  \t\t\t}\n-\t\t\telsif ($other =~ /k/ && $line =~ /^k/) {\n-\t\t\t\twhile (1) {\n-\t\t\t\t\t$ix--;\n-\t\t\t\t\tlast if (!$ix ||\n-\t\t\t\t\t\t !defined $hunk[$ix]{USE});\n+\t\t\telsif ($line =~ /^k/) {\n+\t\t\t\tif ($other =~ /k/) {\n+\t\t\t\t\twhile (1) {\n+\t\t\t\t\t\t$ix--;\n+\t\t\t\t\t\tlast if (!$ix ||\n+\t\t\t\t\t\t\t !defined $hunk[$ix]{USE});\n+\t\t\t\t\t}\n+\t\t\t\t\tnext;\n+\t\t\t\t}\n+\t\t\t\telse {\n+\t\t\t\t\tprint STDERR \"No previous hunk\\n\";\n  \t\t\t\t}\n-\t\t\t\tnext;\n  \t\t\t}\n-\t\t\telsif ($other =~ /j/ && $line =~ /^j/) {\n-\t\t\t\twhile (1) {\n-\t\t\t\t\t$ix++;\n-\t\t\t\t\tlast if ($ix >= $num ||\n-\t\t\t\t\t\t !defined $hunk[$ix]{USE});\n+\t\t\telsif ($line =~ /^j/) {\n+\t\t\t\tif ($other !~ /j/) {\n+\t\t\t\t\tprint STDERR \"No next hunk\\n\";\n+\t\t\t\t\tnext;\n  \t\t\t\t}\n-\t\t\t\tnext;\n  \t\t\t}\n  \t\t\telsif ($other =~ /s/ && $line =~ /^s/) {\n  \t\t\t\tmy @split = split_hunk($hunk[$ix]{TEXT}, $hunk[$ix]{DISPLAY});\n-- \n1.6.0.4.781.gf2070.dirty\n\n\n-- \nWilliam Pursell\n"},{"id":"96586","messageId":"7vej0ydue4.fsf@gitster.siamese.dyndns.org","threadId":"16484","inReplyTo":"492DB6CE.3010409@gmail.com","subject":"Re: [PATCH 2/2] In add --patch, Handle K,k,J,j slightly more gracefully.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-11-26T21:55:47Z","receivedAt":"2008-11-26T21:55:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"William Pursell <bill.pursell@gmail.com> writes:\n\n> Instead of printing the help menu, this will print\n> \"No next hunk\" and then process the given hunk again.\n> ---\n\nMissing sign-off.\n\n> -\t\t\telsif ($other =~ /K/ && $line =~ /^K/) {\n> -\t\t\t\t$ix--;\n> +\t\t\telsif ( $line =~ /^K/) {\n> +\t\t\t\t$other =~ /K/ ?  $ix-- : print STDERR \"No previous hunk\\n\";\n\nThis may be cute but I think it is harder to read than necessary.\n\n\tif ($other =~ /K/) {\n        \t$ix--;\n        } else {\n\t\tprint STDERR \"No previous hunk\\n\";\n        }\n\n> +\t\t\telsif ($line =~ /^k/) {\n> +\t\t\t\tif ($other =~ /k/) {\n> +\t\t\t\t\twhile (1) {\n> +\t\t\t\t\t\t$ix--;\n> +\t\t\t\t\t\tlast if (!$ix ||\n> +\t\t\t\t\t\t\t !defined $hunk[$ix]{USE});\n> +\t\t\t\t\t}\n> +\t\t\t\t\tnext;\n> +\t\t\t\t}\n> +\t\t\t\telse {\n> +\t\t\t\t\tprint STDERR \"No previous hunk\\n\";\n>  \t\t\t\t}\n> -\t\t\t\tnext;\n>  \t\t\t}\n> +\t\t\telsif ($line =~ /^j/) {\n> +\t\t\t\tif ($other !~ /j/) {\n> +\t\t\t\t\tprint STDERR \"No next hunk\\n\";\n> +\t\t\t\t\tnext;\n>  \t\t\t\t}\n>  \t\t\t}\n\nDoesn't this behave differently against an unavailable 'k' and 'j'?  When\nthe user says 'j' when no next hunk is available, it will ask again about\nthat hunk, but when the user says 'k' at the first hunk, because you\ndiscarded 'next', it will ask about the next hunk, no?  Shouldn't it ask\nagain about the same hunk, against which the user gave an erroneous input?\n"}]}