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

[PATCH v1] perf/aggregate: tighten option parsing

From
Christian Couder <christian.couder@gmail.com>
Date
Apr 20, 2018, 12:10 UTC
Message-ID
<20180420121041.32558-1-chriscool@tuxfamily.org>

When passing an option '--foo' that it does not recognize, the aggregate.perl script should die with an helpful error message like:

  unknown option '--foo' at ./aggregate.perl line 80.
rather than:
  fatal: Needed a single revision
  rev-parse --verify --foo: command returned error: 128

While at it let's also prevent something like 'foo--sort-by=regression' to be handled as if '--sort-by=regression' had been used.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 t/perf/aggregate.perl | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/t/perf/aggregate.perl b/t/perf/aggregate.perl
index 48637ef64b..2cc9eb0ac5 100755
--- a/t/perf/aggregate.perl
+++ b/t/perf/aggregate.perl
@@ -46,7 +46,7 @@ while (scalar @ARGV) {
 		shift @ARGV;
 		next;
 	}
-	if ($arg =~ /--sort-by(?:=(.*))?/) {
+	if ($arg =~ /^--sort-by(?:=(.*))?$/) {
 		shift @ARGV;
 		if (defined $1) {
 			$sortby = $1;
@@ -76,6 +76,9 @@ while (scalar @ARGV) {
 		}
 		next;
 	}
+	if ($arg =~ /^--.+$/) {
+		die "unknown option '$arg'";
+	}
 	last if -f $arg or $arg eq "--";
 	if (! -d $arg) {
 		my $rev = Git::command_oneline(qw(rev-parse --verify), $arg);
-- 
2.17.0.257.g28b659db43
Next: Eric Sunshine
Message 1 of 5 in “perf/aggregate: tighten option parsing”
  1. perf/aggregate: tighten option parsingChristian Couder, Apr 20, 2018
  2. Eric SunshineApr 20, 2018
  3. Ævar Arnfjörð BjarmasonApr 20, 2018
  4. Junio C HamanoApr 21, 2018
  5. Christian CouderApr 25, 2018

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.