git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Boyd <bebarino@gmail.com>
To: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>
Cc: git list <git@vger.kernel.org>,
	Junio C Hamano <gitster@pobox.com>,
	Pierre Habouzit <madcoder@madism.org>
Subject: Re: parse-options: ambiguous LASTARG_DEFAULT and OPTARG
Date: Sat, 06 Jun 2009 13:14:42 -0700	[thread overview]
Message-ID: <4A2ACE32.8080504@gmail.com> (raw)
In-Reply-To: <4A2A4534.80604@lsrfire.ath.cx>

René Scharfe wrote:
> PARSE_OPT_OPTARG overrides PARSE_OPT_LASTARG_DEFAULT, as Pierre noted in
> commit 1cc6985c, which introduced the latter, so the two should not be
> used together.

Ok, thanks. This means I used it wrong when I switched over show-branch
:-/ I'll have to send a follow-up patch for that.

> PARSE_OPT_LASTARG_DEFAULT uses the default value if the option is the
> last one on the command line and requires an explicit argument if it's
> not the last, as you found out above.  That's also what the code says
> and its name implies; the comment in parse-options.h (by yours truly)
> is probably misleading because it doesn't mention this condition.

I was mislead. When I read it I thought I had to use the flag to say
that the default value will be used in the case when no argument is
given. I completely ignored the LASTARG part (I thought it was
referencing the default arg). I think just adding what you said here to
parse-options.h will help others to avoid this.

> I don't remember any other program having options with such a
> behaviour; I'm not sure how to stress that --merged needs to be the
> last option, as implied by the help message.

"git tag --contains" is the same. Figuring out a way to say that the
syntax changes when it's the last option versus in the middle is not
obvious to me either.

  reply	other threads:[~2009-06-06 20:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-05  5:43 parse-options: ambiguous LASTARG_DEFAULT and OPTARG Stephen Boyd
2009-06-06 10:30 ` René Scharfe
2009-06-06 20:14   ` Stephen Boyd [this message]
2009-06-07 23:39     ` [PATCH] show-branch: don't use LASTARG_DEFAULT with OPTARG Stephen Boyd
2009-06-08 17:24       ` René Scharfe
2009-06-08 21:56       ` Junio C Hamano
2009-06-09  8:23         ` [PATCH] parse-options: add parse_options_check to validate option specs Pierre Habouzit
2009-06-12 19:31           ` Pierre Habouzit
2009-06-12 21:25             ` René Scharfe

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=4A2ACE32.8080504@gmail.com \
    --to=bebarino@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=madcoder@madism.org \
    --cc=rene.scharfe@lsrfire.ath.cx \
    /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).