From: Andreas Schwab <schwab@linux-m68k.org>
To: Johannes Sixt <j.sixt@viscovery.net>
Cc: Pierre Habouzit <madcoder@debian.org>,
Git Mailing List <git@vger.kernel.org>
Subject: Re: 'git branch --no-merge' is ambiguous
Date: Fri, 25 Sep 2009 20:44:44 +0200 [thread overview]
Message-ID: <m2ljk250f7.fsf@igel.home> (raw)
In-Reply-To: <4ABC9B69.5010205@viscovery.net> (Johannes Sixt's message of "Fri, 25 Sep 2009 12:28:57 +0200")
Johannes Sixt <j.sixt@viscovery.net> writes:
> Look here:
>
> $ git branch --merge
> * master
> $ git branch --no-merge
> error: Ambiguous option: no-merge (could be --no-merged or --no-merged)
> usage: ...
> --no-merged <commit> print only not merged branches
> --merged <commit> print only merged branches
>
> I tried to debug it, but parse_long_opt() is such awful spaghetti code
> that I don't grok it. Please help.
parse_long_opt always matches both --opt and --no-opt for any option
"opt", and only get_value checks whether --no-opt is actually valid.
Since the options for git branch contains both "no-merged" and "merged"
there are two matches for --no-merge, but no exact match. With this
patch the negation of a NONEG option is rejected earlier, but it changes
the error message from "option `no-opt' isn't available" to "unknown
option `no-opt'".
diff --git a/parse-options.c b/parse-options.c
index a64a4d6..f559411 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -230,6 +230,9 @@ is_abbreviated:
abbrev_flags = flags;
continue;
}
+ /* negation allowed? */
+ if (options->flags & PARSE_OPT_NONEG)
+ continue;
/* negated and abbreviated very much? */
if (!prefixcmp("no-", arg)) {
flags |= OPT_UNSET;
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
next prev parent reply other threads:[~2009-09-25 18:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-25 10:28 'git branch --no-merge' is ambiguous Johannes Sixt
2009-09-25 18:44 ` Andreas Schwab [this message]
2009-09-27 7:33 ` Jeff King
2009-09-27 8:01 ` Andreas Schwab
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2ljk250f7.fsf@igel.home \
--to=schwab@linux-m68k.org \
--cc=git@vger.kernel.org \
--cc=j.sixt@viscovery.net \
--cc=madcoder@debian.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).