git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] git-add--interactive: Improve behavior on bogus input

From
JHJean-Luc Herren <jlh@gmx.ch>
Date
Sep 26, 2007, 14:05 UTC
Message-ID
<46FA670D.1060205@gmx.ch>
1) Previously, any menu would cause a perl error when entered '0',
   which is never a valid option.
2) Entering a bogus choice (like 998 or 4-2) surprisingly caused
   the same behavior as if the user had just hit 'enter', which
   means to carry out the selected action on the selected items.
   Entering such bogus input is now a no-op and the sub-menu
   doesn't exit.
Signed-off-by: Jean-Luc Herren <jlh@gmx.ch>
---
 git-add--interactive.perl |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index f9e9f02..be68814 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -219,7 +219,7 @@ sub list_and_choose {
 			last;
 		}
 		chomp $line;
-		my $donesomething = 0;
+		last if $line eq '';
 		for my $choice (split(/[\s,]+/, $line)) {
 			my $choose = 1;
 			my ($bottom, $top);
@@ -251,12 +251,11 @@ sub list_and_choose {
 				next TOPLOOP;
 			}
 			for ($i = $bottom-1; $i <= $top-1; $i++) {
-				next if (@stuff <= $i);
+				next if (@stuff <= $i || $i < 0);
 				$chosen[$i] = $choose;
-				$donesomething++;
 			}
 		}
-		last if (!$donesomething || $opts->{IMMEDIATE});
+		last if ($opts->{IMMEDIATE});
 	}
 	for ($i = 0; $i < @stuff; $i++) {
 		if ($chosen[$i]) {
-- 
1.5.3
Message 1 of 1 in “git-add--interactive: Improve behavior on bogus input”
  1. 2/2 git-add--interactive: Improve behavior on bogus inputJean-Luc Herren, Sep 26, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.