diff options
author | Junio C Hamano <junkio@cox.net> | 2007-05-22 22:52:59 -0700 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2007-05-23 00:17:51 -0700 |
commit | 32309f54ed4b71510f67f2376d755cd2733f29b1 (patch) | |
tree | d6720e562ca9017672f1b0dff29f01d16de447dc /builtin-revert.c | |
parent | 2555699aa2863861e32d222ede2c3df2dbf92088 (diff) | |
download | git-32309f54ed4b71510f67f2376d755cd2733f29b1.tar.gz git-32309f54ed4b71510f67f2376d755cd2733f29b1.tar.xz |
Fix command line parameter parser of revert/cherry-pick
The parser was inconsistently done, in that it did not look at
the last command line parameter to see if it could be an unknown
option, although it was designed to notice unknown options if
they were given in positions the command expects to find them
(i.e. everything except the last parameter, which ought to be
<commit-ish>). This prevented a very natural invocation
$ git cherry-pick --usage
from issuing the usage help.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'builtin-revert.c')
-rw-r--r-- | builtin-revert.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/builtin-revert.c b/builtin-revert.c index ea2f15b97..80c348c40 100644 --- a/builtin-revert.c +++ b/builtin-revert.c @@ -45,8 +45,10 @@ static void parse_options(int argc, const char **argv) if (argc < 2) usage(usage_str); - for (i = 1; i < argc - 1; i++) { + for (i = 1; i < argc; i++) { arg = argv[i]; + if (arg[0] != '-') + break; if (!strcmp(arg, "-n") || !strcmp(arg, "--no-commit")) no_commit = 1; else if (!strcmp(arg, "-e") || !strcmp(arg, "--edit")) @@ -59,7 +61,8 @@ static void parse_options(int argc, const char **argv) else if (strcmp(arg, "-r")) usage(usage_str); } - + if (i != argc - 1) + usage(usage_str); arg = argv[argc - 1]; if (get_sha1(arg, sha1)) die ("Cannot find '%s'", arg); |