{"thread":{"id":"14449","subject":"[PATCH] Make git-add -i accept ranges like 7-","startedAt":"2008-07-14T18:06:24Z","lastAt":"2008-07-14T18:29:37Z","messageCount":3,"participants":["Ciaran McCreesh","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"83279","messageId":"1216058784-32584-1-git-send-email-ciaran.mccreesh@googlemail.com","threadId":"14449","inReplyTo":null,"subject":"[PATCH] Make git-add -i accept ranges like 7-","fromName":"Ciaran McCreesh","fromEmail":"ciaran.mccreesh@googlemail.com","sentAt":"2008-07-14T18:06:24Z","receivedAt":"2008-07-14T18:06:24Z","isPatch":true,"sender":{"key":"ciaran.mccreesh@googlemail.com","avatar":"https://gravatar.com/avatar/2b6d636bccfecedc57b9980bd56beb13679184f4b26bc7239b166ed93e9b210e?d=mp&s=160"},"body":"git-add -i ranges expect number-number. But for the supremely lazy, typing in\nthat second number when selecting \"from patch 7 to the end\" is wasted effort.\nSo treat an empty second number in a range as \"until the last item\".\n\nSigned-off-by: Ciaran McCreesh <ciaran.mccreesh@googlemail.com>\n---\n Documentation/git-add.txt |    5 +++--\n git-add--interactive.perl |    6 +++---\n 2 files changed, 6 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/git-add.txt b/Documentation/git-add.txt\nindex 46dd56c..3558905 100644\n--- a/Documentation/git-add.txt\n+++ b/Documentation/git-add.txt\n@@ -187,8 +187,9 @@ update::\n    \"Update>>\".  When the prompt ends with double '>>', you can\n    make more than one selection, concatenated with whitespace or\n    comma.  Also you can say ranges.  E.g. \"2-5 7,9\" to choose\n-   2,3,4,5,7,9 from the list.  You can say '*' to choose\n-   everything.\n+   2,3,4,5,7,9 from the list.  If the second number in a range is\n+   omitted, all remaining patches are taken.  E.g. \"7-\" to choose\n+   7,8,9 from the list.  You can say '*' to choose everything.\n +\n What you chose are then highlighted with '*',\n like this:\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex 801d7c0..72a8858 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -406,9 +406,9 @@ sub list_and_choose {\n \t\t\tif ($choice =~ s/^-//) {\n \t\t\t\t$choose = 0;\n \t\t\t}\n-\t\t\t# A range can be specified like 5-7\n-\t\t\tif ($choice =~ /^(\\d+)-(\\d+)$/) {\n-\t\t\t\t($bottom, $top) = ($1, $2);\n+\t\t\t# A range can be specified like 5-7 or 5-.\n+\t\t\tif ($choice =~ /^(\\d*)-(\\d*)$/) {\n+\t\t\t\t($bottom, $top) = ($1, length($2) ? $2 : 1 + @stuff);\n \t\t\t}\n \t\t\telsif ($choice =~ /^\\d+$/) {\n \t\t\t\t$bottom = $top = $choice;\n-- \n1.5.6.2\n"},{"id":"83281","messageId":"7vfxqcgwni.fsf@gitster.siamese.dyndns.org","threadId":"14449","inReplyTo":"1216058784-32584-1-git-send-email-ciaran.mccreesh@googlemail.com","subject":"Re: [PATCH] Make git-add -i accept ranges like 7-","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-07-14T18:15:13Z","receivedAt":"2008-07-14T18:15:13Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ciaran McCreesh <ciaran.mccreesh@googlemail.com> writes:\n\n> git-add -i ranges expect number-number. But for the supremely lazy, typing in\n> that second number when selecting \"from patch 7 to the end\" is wasted effort.\n> So treat an empty second number in a range as \"until the last item\".\n\nYou didn't describe why you changed the first regexp from \\d+ to \\d*,\nwhich would allow \"-9\" as a valid input as well.\n\nBut in that case $bottom will become an empty string.  Don't you need to\nadjust the users of this data in the codepaths that follow this part?  I\ndidn't check.\n\n> diff --git a/git-add--interactive.perl b/git-add--interactive.perl\n> index 801d7c0..72a8858 100755\n> --- a/git-add--interactive.perl\n> +++ b/git-add--interactive.perl\n> @@ -406,9 +406,9 @@ sub list_and_choose {\n>  \t\t\tif ($choice =~ s/^-//) {\n>  \t\t\t\t$choose = 0;\n>  \t\t\t}\n> -\t\t\t# A range can be specified like 5-7\n> -\t\t\tif ($choice =~ /^(\\d+)-(\\d+)$/) {\n> -\t\t\t\t($bottom, $top) = ($1, $2);\n> +\t\t\t# A range can be specified like 5-7 or 5-.\n> +\t\t\tif ($choice =~ /^(\\d*)-(\\d*)$/) {\n> +\t\t\t\t($bottom, $top) = ($1, length($2) ? $2 : 1 + @stuff);\n>  \t\t\t}\n>  \t\t\telsif ($choice =~ /^\\d+$/) {\n>  \t\t\t\t$bottom = $top = $choice;\n> -- \n> 1.5.6.2\n"},{"id":"83282","messageId":"1216060177-8757-1-git-send-email-ciaran.mccreesh@googlemail.com","threadId":"14449","inReplyTo":"7vfxqcgwni.fsf@gitster.siamese.dyndns.org","subject":"[PATCH,v2] Make git-add -i accept ranges like 7-","fromName":"Ciaran McCreesh","fromEmail":"ciaran.mccreesh@googlemail.com","sentAt":"2008-07-14T18:29:37Z","receivedAt":"2008-07-14T18:29:37Z","isPatch":true,"sender":{"key":"ciaran.mccreesh@googlemail.com","avatar":"https://gravatar.com/avatar/2b6d636bccfecedc57b9980bd56beb13679184f4b26bc7239b166ed93e9b210e?d=mp&s=160"},"body":"git-add -i ranges expect number-number. But for the supremely lazy, typing in\nthat second number when selecting \"from patch 7 to the end\" is wasted effort.\nSo treat an empty second number in a range as \"until the last item\".\n\nSigned-off-by: Ciaran McCreesh <ciaran.mccreesh@googlemail.com>\n---\nOops, my bad.\n\nAttempt 2 changes the regex to require a number in the first half of the range.\nI was planning to allow for -7, meaning 'up to 7', but this collides with - at\nthe start being used to unchoose things. There's not much point adding a\nspecial thing for 'from the start' though, since '1' is only one character to\ntype.\n\n Documentation/git-add.txt |    5 +++--\n git-add--interactive.perl |    6 +++---\n 2 files changed, 6 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/git-add.txt b/Documentation/git-add.txt\nindex 46dd56c..3558905 100644\n--- a/Documentation/git-add.txt\n+++ b/Documentation/git-add.txt\n@@ -187,8 +187,9 @@ update::\n    \"Update>>\".  When the prompt ends with double '>>', you can\n    make more than one selection, concatenated with whitespace or\n    comma.  Also you can say ranges.  E.g. \"2-5 7,9\" to choose\n-   2,3,4,5,7,9 from the list.  You can say '*' to choose\n-   everything.\n+   2,3,4,5,7,9 from the list.  If the second number in a range is\n+   omitted, all remaining patches are taken.  E.g. \"7-\" to choose\n+   7,8,9 from the list.  You can say '*' to choose everything.\n +\n What you chose are then highlighted with '*',\n like this:\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex 801d7c0..a6a5c52 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -406,9 +406,9 @@ sub list_and_choose {\n \t\t\tif ($choice =~ s/^-//) {\n \t\t\t\t$choose = 0;\n \t\t\t}\n-\t\t\t# A range can be specified like 5-7\n-\t\t\tif ($choice =~ /^(\\d+)-(\\d+)$/) {\n-\t\t\t\t($bottom, $top) = ($1, $2);\n+\t\t\t# A range can be specified like 5-7 or 5-.\n+\t\t\tif ($choice =~ /^(\\d+)-(\\d*)$/) {\n+\t\t\t\t($bottom, $top) = ($1, length($2) ? $2 : 1 + @stuff);\n \t\t\t}\n \t\t\telsif ($choice =~ /^\\d+$/) {\n \t\t\t\t$bottom = $top = $choice;\n-- \n1.5.6.2\n"}]}