git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] perf/aggregate: tighten option parsing
@ 2018-04-20 12:10 Christian Couder
  2018-04-20 17:46 ` Eric Sunshine
  0 siblings, 1 reply; 5+ messages in thread
From: Christian Couder @ 2018-04-20 12:10 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Ævar Arnfjörð Bjarmason,
	Christian Couder

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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-04-25 12:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-20 12:10 [PATCH v1] perf/aggregate: tighten option parsing Christian Couder
2018-04-20 17:46 ` Eric Sunshine
2018-04-20 18:27   ` Ævar Arnfjörð Bjarmason
2018-04-21  3:50     ` Junio C Hamano
2018-04-25 12:55       ` Christian Couder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).