summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-02-12 10:27:17 -0800
committerJunio C Hamano <gitster@pobox.com>2017-02-12 10:45:18 -0800
commit46cd78b86501925f79987faa48e57f6b0297be66 (patch)
tree2a28fdd9a616a40310f7fb72a0011093fdebe6f5
parent9dd59d8b862961dbe53d7ee09f186c60bc4e84cc (diff)
downloadgit-jc/setup-revisions-unknown-opt.tar.gz
setup_revisions(): allow a rev that begins with a dashjc/setup-revisions-unknown-opt
Now that all the preparatory pieces are in place, it is just a matter of handling a truly unknown option _after_ handle_revision_arg() decides that arg is not a rev. Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--revision.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/revision.c b/revision.c
index eccf1ab695..0f772ba73d 100644
--- a/revision.c
+++ b/revision.c
@@ -2203,6 +2203,8 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
read_from_stdin = 0;
for (left = i = 1; i < argc; i++) {
const char *arg = argv[i];
+ int maybe_opt = 0;
+
if (*arg == '-') {
int opts;
@@ -2232,13 +2234,20 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
}
if (opts < 0)
exit(128);
- /* arg looks like an opt but something we do not recognise. */
- argv[left++] = arg;
- continue;
+ /*
+ * arg looks like an opt but something we do not recognise.
+ * It may be a rev that begins with a dash; fall through to
+ * let handle_revision_arg() have a say in this.
+ */
+ maybe_opt = 1;
}
if (!handle_revision_arg(arg, revs, flags, revarg_opt)) {
got_rev_arg = 1;
+ } else if (maybe_opt) {
+ /* it turns out that it is not a rev after all */
+ argv[left++] = arg;
+ continue;
} else {
int j;
if (seen_dashdash || *arg == '^')