git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Nicolas Vigier <boklm@mars-attacks.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Pierre Habouzit <madcoder@debian.org>
Subject: Re: [PATCH] rev-parse --parseopt: fix handling of optional arguments
Date: Wed, 16 Oct 2013 01:47:01 +0200	[thread overview]
Message-ID: <20131015234701.GY4589@mars-attacks.org> (raw)
In-Reply-To: <xmqq4n8ib0uv.fsf@gitster.dls.corp.google.com>

On Tue, 15 Oct 2013, Junio C Hamano wrote:

> Nicolas Vigier <boklm@mars-attacks.org> writes:
> 
> > git rev-parse --parseopt does not allow us to see the difference
> > between an option with an optional argument starting with a dash, and an
> > option with an unset optional argument followed by an other option.
> >
> > If I use this script :
> >
> >   $ cat /tmp/opt.sh
> >   #!/bin/sh
> >   OPTIONS_SPEC="\
> >   git [options]
> >   --
> >   q,quiet         be quiet
> >   S,gpg-sign?     GPG-sign commit"
> >   echo "$OPTIONS_SPEC" | git rev-parse --parseopt $parseopt_extra -- "$@"
> >
> > Then the following two commands give us the same result :
> >
> >   $ /tmp/opt.sh -S -q
> >   set -- -S -q --
> >   $ /tmp/opt.sh -S-q
> >   set -- -S '-q' --
> >
> > We cannot know if '-q' is an argument to '-S' or a new option.
> >
> > With this patch, rev-parse --parseopt will always give an argument to
> > optional options, as an empty string if the argument is unset.
> >
> > The same two commands now give us :
> >
> >   $ /tmp/opt.sh -S -q
> >   set -- -S '' -q --
> >   $ /tmp/opt.sh -S-q
> >   set -- -S '-q' --
> 
> Two are different, but the former "set -- -S '' -q --" is not what
> you want, either, no?  -S with an explicit empty argument and -S
> alone without argument may mean two totally different things, which
> is the whole point of "option with an optional parameter".  If some
> code that have been using "rev-parse --parseopt" was happy with
> 
> 	$ /tmp/opt.sh -S
>         set -- -S --
> 
> and then your updated version gave it this instead:
> 
> 	$ /tmp/opt.sh -S
>         set -- -S '' --
> 
> wouldn't it be a regression to them?

Indeed, this could be a regression to them. I couldn't find any script
using "rev-parse --parseopt" with an option with an optional argument,
but yes, it doesn't mean that nobody uses that.

  reply	other threads:[~2013-10-15 23:47 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-15 12:00 [PATCH] rev-parse --parseopt: fix handling of optional arguments Nicolas Vigier
2013-10-15 22:55 ` Junio C Hamano
2013-10-15 23:47   ` Nicolas Vigier [this message]
2013-10-15 23:14 ` Jonathan Nieder
2013-10-15 23:33   ` Junio C Hamano
2013-10-15 23:57     ` Jonathan Nieder
2013-10-16  7:04       ` Johannes Sixt
2013-10-16  8:53         ` Jeff King
2013-10-16 21:40           ` Junio C Hamano
2013-10-16 21:50             ` Jeff King
2013-10-16 10:58         ` Nicolas Vigier
2013-10-16 14:14       ` Nicolas Vigier
2013-10-16 22:33         ` Jonathan Nieder
2013-10-25 20:18           ` [PATCH] rev-parse --parseopt: add the --sticked-long mode Nicolas Vigier
2013-10-25 22:01             ` Junio C Hamano
2013-10-25 22:52               ` Nicolas Vigier
2013-10-25 22:55                 ` Junio C Hamano
2013-10-26 21:55                   ` Philip Oakley
2013-10-28 15:47                     ` Junio C Hamano
2013-10-31 11:08               ` sticked -> stuck Nicolas Vigier
2013-10-31 11:08                 ` [PATCH 1/2] Use the word 'stuck' instead of 'sticked' Nicolas Vigier
2013-10-31 19:35                   ` Junio C Hamano
2013-10-31 11:08                 ` [PATCH 2/2] rev-parse --parseopt: add the --stuck-long mode Nicolas Vigier
2013-10-27  5:45             ` [PATCH] rev-parse --parseopt: add the --sticked-long mode Michael Haggerty
2013-10-15 23:53   ` [PATCH] rev-parse --parseopt: fix handling of optional arguments Nicolas Vigier

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131015234701.GY4589@mars-attacks.org \
    --to=boklm@mars-attacks.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).