{"thread":{"id":"17495","subject":"[PATCH 0/3] \"add -p\" enhancements","startedAt":"2009-02-02T03:42:36Z","lastAt":"2009-02-02T09:17:28Z","messageCount":7,"participants":["Junio C Hamano","William Pursell"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"102814","messageId":"1233546159-30347-1-git-send-email-gitster@pobox.com","threadId":"17495","inReplyTo":null,"subject":"[PATCH 0/3] \"add -p\" enhancements","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-02-02T03:42:36Z","receivedAt":"2009-02-02T03:42:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"I've looked at an earlier series by William Pursell to add \"Find hunk\"\naction to \"git add -p\" and it was fairly trivial to resurrect.  I'll be\nqueuing them to 'next' unless people object.\n\nWilliam Pursell (3):\n  git-add -i/-p: Change prompt separater from slash to comma\n  Add / command in add --patch\n  In add --patch, Handle K,k,J,j slightly more gracefully.\n\n git-add--interactive.perl |   81 +++++++++++++++++++++++++++++++++------------\n 1 files changed, 60 insertions(+), 21 deletions(-)\n"},{"id":"102815","messageId":"1233546159-30347-2-git-send-email-gitster@pobox.com","threadId":"17495","inReplyTo":"1233546159-30347-1-git-send-email-gitster@pobox.com","subject":"[PATCH 1/3] git-add -i/-p: Change prompt separater from slash to comma","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-02-02T03:42:37Z","receivedAt":"2009-02-02T03:42:37Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"From: William Pursell <bill.pursell@gmail.com>\n\nOtherwise the find command '/' soon to be introduced will be hard to see.\n\nSigned-off-by: William Pursell <bill.pursell@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n git-add--interactive.perl |   14 +++++++-------\n 1 files changed, 7 insertions(+), 7 deletions(-)\n\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex ca60356..ca50363 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -929,22 +929,22 @@ sub patch_update_file {\n \t\tfor ($i = 0; $i < $ix; $i++) {\n \t\t\tif (!defined $hunk[$i]{USE}) {\n \t\t\t\t$prev = 1;\n-\t\t\t\t$other .= '/k';\n+\t\t\t\t$other .= ',k';\n \t\t\t\tlast;\n \t\t\t}\n \t\t}\n \t\tif ($ix) {\n-\t\t\t$other .= '/K';\n+\t\t\t$other .= ',K';\n \t\t}\n \t\tfor ($i = $ix + 1; $i < $num; $i++) {\n \t\t\tif (!defined $hunk[$i]{USE}) {\n \t\t\t\t$next = 1;\n-\t\t\t\t$other .= '/j';\n+\t\t\t\t$other .= ',j';\n \t\t\t\tlast;\n \t\t\t}\n \t\t}\n \t\tif ($ix < $num - 1) {\n-\t\t\t$other .= '/J';\n+\t\t\t$other .= ',J';\n \t\t}\n \t\tif ($num > 1) {\n \t\t\t$other .= '/g';\n@@ -958,13 +958,13 @@ sub patch_update_file {\n \t\tlast if (!$undecided);\n \n \t\tif (hunk_splittable($hunk[$ix]{TEXT})) {\n-\t\t\t$other .= '/s';\n+\t\t\t$other .= ',s';\n \t\t}\n-\t\t$other .= '/e';\n+\t\t$other .= ',e';\n \t\tfor (@{$hunk[$ix]{DISPLAY}}) {\n \t\t\tprint;\n \t\t}\n-\t\tprint colored $prompt_color, \"Stage this hunk [y/n/a/d$other/?]? \";\n+\t\tprint colored $prompt_color, \"Stage this hunk [y,n,a,d$other,?]? \";\n \t\tmy $line = <STDIN>;\n \t\tif ($line) {\n \t\t\tif ($line =~ /^y/i) {\n-- \n1.6.1.2.331.g8c4c8\n"},{"id":"102817","messageId":"1233546159-30347-3-git-send-email-gitster@pobox.com","threadId":"17495","inReplyTo":"1233546159-30347-2-git-send-email-gitster@pobox.com","subject":"[PATCH 2/3] Add / command in add --patch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-02-02T03:42:38Z","receivedAt":"2009-02-02T03:42:38Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"From: William Pursell <bill.pursell@gmail.com>\n\nThis command allows the user to skip hunks that don't match the specified\nregex.\n\nSigned-off-by: William Pursell <bill.pursell@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n git-add--interactive.perl |   28 +++++++++++++++++++++++++++-\n 1 files changed, 27 insertions(+), 1 deletions(-)\n\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex ca50363..64ad289 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -801,6 +801,7 @@ n - do not stage this hunk\n a - stage this and all the remaining hunks in the file\n d - do not stage this hunk nor any of the remaining hunks in the file\n g - select a hunk to go to\n+/ - search for a hunk matching the given regex\n j - leave this hunk undecided, see next undecided hunk\n J - leave this hunk undecided, see next hunk\n k - leave this hunk undecided, see previous undecided hunk\n@@ -964,7 +965,7 @@ sub patch_update_file {\n \t\tfor (@{$hunk[$ix]{DISPLAY}}) {\n \t\t\tprint;\n \t\t}\n-\t\tprint colored $prompt_color, \"Stage this hunk [y,n,a,d$other,?]? \";\n+\t\tprint colored $prompt_color, \"Stage this hunk [y,n,a,d,/$other,?]? \";\n \t\tmy $line = <STDIN>;\n \t\tif ($line) {\n \t\t\tif ($line =~ /^y/i) {\n@@ -1013,6 +1014,31 @@ sub patch_update_file {\n \t\t\t\t}\n \t\t\t\tnext;\n \t\t\t}\n+\t\t\telsif ($line =~ m|^/(.*)|) {\n+\t\t\t\tmy $search_string;\n+\t\t\t\teval {\n+\t\t\t\t\t$search_string = qr{$1}m;\n+\t\t\t\t};\n+\t\t\t\tif ($@) {\n+\t\t\t\t\tmy ($err,$exp) = ($@, $1);\n+\t\t\t\t\t$err =~ s/ at .*git-add--interactive line \\d+, <STDIN> line \\d+.*$//;\n+\t\t\t\t\tprint STDERR \"Malformed search regexp $exp: $err\\n\";\n+\t\t\t\t\tnext;\n+\t\t\t\t}\n+\t\t\t\tmy $iy = $ix;\n+\t\t\t\twhile (1) {\n+\t\t\t\t\tmy $text = join (\"\", @{$hunk[$iy]{TEXT}});\n+\t\t\t\t\tlast if ($text =~ $search_string);\n+\t\t\t\t\t$iy++;\n+\t\t\t\t\t$iy = 0 if ($iy >= $num);\n+\t\t\t\t\tif ($ix == $iy) {\n+\t\t\t\t\t\tprint STDERR \"No hunk matches the given pattern\\n\";\n+\t\t\t\t\t\tlast;\n+\t\t\t\t\t}\n+\t\t\t\t}\n+\t\t\t\t$ix = $iy;\n+\t\t\t\tnext;\n+\t\t\t}\n \t\t\telsif ($other =~ /K/ && $line =~ /^K/) {\n \t\t\t\t$ix--;\n \t\t\t\tnext;\n-- \n1.6.1.2.331.g8c4c8\n"},{"id":"102816","messageId":"1233546159-30347-4-git-send-email-gitster@pobox.com","threadId":"17495","inReplyTo":"1233546159-30347-3-git-send-email-gitster@pobox.com","subject":"[PATCH 3/3] In add --patch, Handle K,k,J,j slightly more gracefully.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-02-02T03:42:39Z","receivedAt":"2009-02-02T03:42:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"From: William Pursell <bill.pursell@gmail.com>\n\nInstead of printing the help menu, this will print \"No next hunk\" and then\nprocess the given hunk again.\n\nSigned-off-by: William Pursell <bill.pursell@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n git-add--interactive.perl |   43 ++++++++++++++++++++++++++++---------------\n 1 files changed, 28 insertions(+), 15 deletions(-)\n\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex 64ad289..30ddab2 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -1039,29 +1039,42 @@ sub patch_update_file {\n \t\t\t\t$ix = $iy;\n \t\t\t\tnext;\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\tif ($other =~ /K/) {\n+\t\t\t\t\t$ix--;\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\t$ix++;\n+\t\t\telsif ($line =~ /^J/) {\n+\t\t\t\tif ($other =~ /J/) {\n+\t\t\t\t\t$ix++;\n+\t\t\t\t}\n+\t\t\t\telse {\n+\t\t\t\t\tprint STDERR \"No next hunk\\n\";\n+\t\t\t\t}\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}\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.1.2.331.g8c4c8\n"},{"id":"102833","messageId":"4986A334.6070903@gmail.com","threadId":"17495","inReplyTo":"1233546159-30347-2-git-send-email-gitster@pobox.com","subject":"Re: [PATCH 1/3] git-add -i/-p: Change prompt separater from slash to comma","fromName":"William Pursell","fromEmail":"bill.pursell@gmail.com","sentAt":"2009-02-02T07:39:32Z","receivedAt":"2009-02-02T07:39:32Z","isPatch":true,"sender":{"key":"bill.pursell@gmail.com","avatar":"https://gravatar.com/avatar/3ab4313e5dfdc1fedb65206d829ba33f71f56f26e11326979d1b99d5e1c403c9?d=mp&s=160"},"body":"Junio C Hamano wrote:\n> From: William Pursell <bill.pursell@gmail.com>\n> \n> Otherwise the find command '/' soon to be introduced will be hard to see.\n> \n> Signed-off-by: William Pursell <bill.pursell@gmail.com>\n> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n> ---\n>  git-add--interactive.perl |   14 +++++++-------\n>  1 files changed, 7 insertions(+), 7 deletions(-)\n> \n> diff --git a/git-add--interactive.perl b/git-add--interactive.perl\n> index ca60356..ca50363 100755\n> --- a/git-add--interactive.perl\n> +++ b/git-add--interactive.perl\n> @@ -929,22 +929,22 @@ sub patch_update_file {\n>  \t\tfor ($i = 0; $i < $ix; $i++) {\n>  \t\t\tif (!defined $hunk[$i]{USE}) {\n>  \t\t\t\t$prev = 1;\n> -\t\t\t\t$other .= '/k';\n> +\t\t\t\t$other .= ',k';\n>  \t\t\t\tlast;\n>  \t\t\t}\n>  \t\t}\n>  \t\tif ($ix) {\n> -\t\t\t$other .= '/K';\n> +\t\t\t$other .= ',K';\n>  \t\t}\n>  \t\tfor ($i = $ix + 1; $i < $num; $i++) {\n>  \t\t\tif (!defined $hunk[$i]{USE}) {\n>  \t\t\t\t$next = 1;\n> -\t\t\t\t$other .= '/j';\n> +\t\t\t\t$other .= ',j';\n>  \t\t\t\tlast;\n>  \t\t\t}\n>  \t\t}\n>  \t\tif ($ix < $num - 1) {\n> -\t\t\t$other .= '/J';\n> +\t\t\t$other .= ',J';\n>  \t\t}\n>  \t\tif ($num > 1) {\n>  \t\t\t$other .= '/g';\n> @@ -958,13 +958,13 @@ sub patch_update_file {\n>  \t\tlast if (!$undecided);\n>  \n>  \t\tif (hunk_splittable($hunk[$ix]{TEXT})) {\n> -\t\t\t$other .= '/s';\n> +\t\t\t$other .= ',s';\n>  \t\t}\n> -\t\t$other .= '/e';\n> +\t\t$other .= ',e';\n>  \t\tfor (@{$hunk[$ix]{DISPLAY}}) {\n>  \t\t\tprint;\n>  \t\t}\n> -\t\tprint colored $prompt_color, \"Stage this hunk [y/n/a/d$other/?]? \";\n> +\t\tprint colored $prompt_color, \"Stage this hunk [y,n,a,d$other,?]? \";\n>  \t\tmy $line = <STDIN>;\n>  \t\tif ($line) {\n>  \t\t\tif ($line =~ /^y/i) {\n\n\nNot a major complaint, but how about localizing the occurence\nof the separator.  Something like this:\n\n\n\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex ca60356..bd8326d 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -921,7 +921,7 @@ sub patch_update_file {\n\n \twhile (1) {\n \t\tmy ($prev, $next, $other, $undecided, $i);\n-\t\t$other = '';\n+\t\t$other = 'ynad';\n\n \t\tif ($num <= $ix) {\n \t\t\t$ix = 0;\n@@ -929,25 +929,25 @@ sub patch_update_file {\n \t\tfor ($i = 0; $i < $ix; $i++) {\n \t\t\tif (!defined $hunk[$i]{USE}) {\n \t\t\t\t$prev = 1;\n-\t\t\t\t$other .= '/k';\n+\t\t\t\t$other .= 'k';\n \t\t\t\tlast;\n \t\t\t}\n \t\t}\n \t\tif ($ix) {\n-\t\t\t$other .= '/K';\n+\t\t\t$other .= 'K';\n \t\t}\n \t\tfor ($i = $ix + 1; $i < $num; $i++) {\n \t\t\tif (!defined $hunk[$i]{USE}) {\n \t\t\t\t$next = 1;\n-\t\t\t\t$other .= '/j';\n+\t\t\t\t$other .= 'j';\n \t\t\t\tlast;\n \t\t\t}\n \t\t}\n \t\tif ($ix < $num - 1) {\n-\t\t\t$other .= '/J';\n+\t\t\t$other .= 'J';\n \t\t}\n \t\tif ($num > 1) {\n-\t\t\t$other .= '/g';\n+\t\t\t$other .= 'g';\n \t\t}\n \t\tfor ($i = 0; $i < $num; $i++) {\n \t\t\tif (!defined $hunk[$i]{USE}) {\n@@ -958,13 +958,14 @@ sub patch_update_file {\n \t\tlast if (!$undecided);\n\n \t\tif (hunk_splittable($hunk[$ix]{TEXT})) {\n-\t\t\t$other .= '/s';\n+\t\t\t$other .= 's';\n \t\t}\n-\t\t$other .= '/e';\n+\t\t$other .= 'e';\n \t\tfor (@{$hunk[$ix]{DISPLAY}}) {\n \t\t\tprint;\n \t\t}\n-\t\tprint colored $prompt_color, \"Stage this hunk [y/n/a/d$other/?]? \";\n+\t\tprint colored $prompt_color, \"Stage this hunk [\" .\n+\t\t\tjoin(',', split(\"\", $other)) . \"]? \";\n \t\tmy $line = <STDIN>;\n \t\tif ($line) {\n \t\t\tif ($line =~ /^y/i) {\n\n\n-- \nWilliam Pursell\n"},{"id":"102835","messageId":"7vy6wpl1mx.fsf@gitster.siamese.dyndns.org","threadId":"17495","inReplyTo":"4986A334.6070903@gmail.com","subject":"Re: [PATCH 1/3] git-add -i/-p: Change prompt separater from slash to comma","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-02-02T07:49:10Z","receivedAt":"2009-02-02T07:49:10Z","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> Not a major complaint, but how about localizing the occurence\n> of the separator.  Something like this:\n\nI think that is sensible.  I've already queued the resurrected series to\n'next' and am deep in the process of tonight's pushout preparation (this\ntime I've even written What's cooking), so I'd rather not rewind what I\nhave already and redo it.  Could you send an incremental update on top of\nwhat's in next (more specifically ace30ba (In add --patch, Handle K,k,J,j\nslightly more gracefully., 2008-11-27) please?\n"},{"id":"102848","messageId":"4986BA28.10608@gmail.com","threadId":"17495","inReplyTo":"7vy6wpl1mx.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 1/3] git-add -i/-p: Change prompt separater from slash to comma","fromName":"William Pursell","fromEmail":"bill.pursell@gmail.com","sentAt":"2009-02-02T09:17:28Z","receivedAt":"2009-02-02T09:17:28Z","isPatch":true,"sender":{"key":"bill.pursell@gmail.com","avatar":"https://gravatar.com/avatar/3ab4313e5dfdc1fedb65206d829ba33f71f56f26e11326979d1b99d5e1c403c9?d=mp&s=160"},"body":"Junio C Hamano wrote:\n> William Pursell <bill.pursell@gmail.com> writes:\n> \n>> Not a major complaint, but how about localizing the occurence\n>> of the separator.  Something like this:\n> \n> I think that is sensible.  I've already queued the resurrected series to\n> 'next' and am deep in the process of tonight's pushout preparation (this\n> time I've even written What's cooking), so I'd rather not rewind what I\n> have already and redo it.  Could you send an incremental update on top of\n> what's in next (more specifically ace30ba (In add --patch, Handle K,k,J,j\n> slightly more gracefully., 2008-11-27) please?\n\nHere's a patch against ace30ba.  Minor change from the initial\npatch includes adding '?' to the join argument for consistency\nwith previous prompt string, and adding '/' to the initialization\nof $other to accomodate dd971cc.\n\n\nLocalize the command separator.\n\nSigned-off-by: William Pursell <bill.pursell@gmail.com>\n---\n git-add--interactive.perl |   19 ++++++++++---------\n 1 files changed, 10 insertions(+), 9 deletions(-)\n\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex 30ddab2..4500e62 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -922,7 +922,7 @@ sub patch_update_file {\n\n \twhile (1) {\n \t\tmy ($prev, $next, $other, $undecided, $i);\n-\t\t$other = '';\n+\t\t$other = 'ynad/';\n\n \t\tif ($num <= $ix) {\n \t\t\t$ix = 0;\n@@ -930,25 +930,25 @@ sub patch_update_file {\n \t\tfor ($i = 0; $i < $ix; $i++) {\n \t\t\tif (!defined $hunk[$i]{USE}) {\n \t\t\t\t$prev = 1;\n-\t\t\t\t$other .= ',k';\n+\t\t\t\t$other .= 'k';\n \t\t\t\tlast;\n \t\t\t}\n \t\t}\n \t\tif ($ix) {\n-\t\t\t$other .= ',K';\n+\t\t\t$other .= 'K';\n \t\t}\n \t\tfor ($i = $ix + 1; $i < $num; $i++) {\n \t\t\tif (!defined $hunk[$i]{USE}) {\n \t\t\t\t$next = 1;\n-\t\t\t\t$other .= ',j';\n+\t\t\t\t$other .= 'j';\n \t\t\t\tlast;\n \t\t\t}\n \t\t}\n \t\tif ($ix < $num - 1) {\n-\t\t\t$other .= ',J';\n+\t\t\t$other .= 'J';\n \t\t}\n \t\tif ($num > 1) {\n-\t\t\t$other .= '/g';\n+\t\t\t$other .= 'g';\n \t\t}\n \t\tfor ($i = 0; $i < $num; $i++) {\n \t\t\tif (!defined $hunk[$i]{USE}) {\n@@ -959,13 +959,14 @@ sub patch_update_file {\n \t\tlast if (!$undecided);\n\n \t\tif (hunk_splittable($hunk[$ix]{TEXT})) {\n-\t\t\t$other .= ',s';\n+\t\t\t$other .= 's';\n \t\t}\n-\t\t$other .= ',e';\n+\t\t$other .= 'e';\n \t\tfor (@{$hunk[$ix]{DISPLAY}}) {\n \t\t\tprint;\n \t\t}\n-\t\tprint colored $prompt_color, \"Stage this hunk [y,n,a,d,/$other,?]? \";\n+\t\tprint colored $prompt_color, \"Stage this hunk [\" .\n+\t\t\tjoin(\",\", split(\"\", $other . \"?\")) . \"]? \";\n \t\tmy $line = <STDIN>;\n \t\tif ($line) {\n \t\t\tif ($line =~ /^y/i) {\n-- \n1.6.1.265.g9a013.dirty\n\n\n\n\n-- \nWilliam Pursell\n"}]}