From: Eric Wong <normalperson@yhbt.net>
To: Linus Torvalds <torvalds@osdl.org>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 5/5] diff: parse U/u/unified options with an optional integer arg
Date: Sun, 14 May 2006 16:36:06 -0700 [thread overview]
Message-ID: <20060514233606.GA10249@hand.yhbt.net> (raw)
In-Reply-To: <Pine.LNX.4.64.0605140931410.3866@g5.osdl.org>
Linus Torvalds <torvalds@osdl.org> wrote:
>
>
> On Sun, 14 May 2006, Eric Wong wrote:
> >
> > -u (lowercase) now accepts an optional arg, like -U (GNU diff
> > -u also has this behavior).
>
> Actually, modern GNU "diff -u5" will say
>
> diff: `-5' option is obsolete; use `-U 5'
> diff: Try `diff --help' for more information.
>
> and exit.
>
> I'm not entirely sure why, but I think it's because "u" can be mixed (ie
> with something like "-urN"), while "U" cannot. The GNU diff rule seems to
> be that simple arguments can be mixed together, but arguments with
> parameters cannot. Which sounds sane.
Interesting. With _POSIX2_VERSION < 200112, diff is happy to accept
-u5. Setting _POSIX2_VERSION >= 200112 causes it to burp, however.
It turns out -u5 is actually short for -u -5, but I (and apparently some
other people) have always assumed -u5 worked like -U5. POSIX doesn't
like -<num> switches, however, but we support it regardless in rev-list.
I prefer that it works the -u5 way, of course :)
Also, I find integer arguments being bundled with other parameters to be
pretty nice feature, but it's easy to disable if users don't like it:
diff --git a/gitopt.c b/gitopt.c
index 9e85247..139cd2d 100644
--- a/gitopt.c
+++ b/gitopt.c
@@ -270,17 +270,9 @@ static const char * parse_bundled(struct
} else if (s->arg_fl) {
if (*cur) {
/* no space between the arg and opt switch: */
- if (s->arg_fl & ARG_IS_INT) {
- /* we know to handle stuff like:
- * -h24w80 => -h=24 -w=80 */
- char *endptr = (char *)cur;
- strtol(cur, &endptr, 10);
-
- while (cur < endptr)
- *c++ = *cur++;
- } else if (s->arg_fl & ARG_ONE) {
- /* unfortunately, other args are less
- * clear-cut */
+ if (s->arg_fl & ARG_ONE) {
+ /* don't attempt further unbundling, extra
+ * chars are arguments */
while (*cur)
*c++ = *cur++;
}
--
Eric Wong
prev parent reply other threads:[~2006-05-14 23:36 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-14 15:19 [PATCH/RFC] gitopt - command-line parsing enhancements (take #2) Eric Wong
2006-05-14 15:19 ` [PATCH 1/5] gitopt: a new command-line option parser for git Eric Wong
2006-05-14 15:19 ` [PATCH 2/5] gitopt: convert ls-files, ls-tree, update-index Eric Wong
2006-05-14 15:19 ` [PATCH 3/5] gitopt: convert setup_revisions() and friends Eric Wong
2006-05-14 15:19 ` [PATCH 4/5] commit: allow --pretty= args to be abbreviated Eric Wong
2006-05-14 23:47 ` Junio C Hamano
2006-05-15 0:34 ` [PATCH] " Eric Wong
2006-05-15 20:47 ` Junio C Hamano
2006-05-16 13:25 ` Eric Wong
2006-05-14 15:19 ` [PATCH 5/5] diff: parse U/u/unified options with an optional integer arg Eric Wong
2006-05-14 16:33 ` Linus Torvalds
2006-05-14 23:36 ` Eric Wong [this message]
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=20060514233606.GA10249@hand.yhbt.net \
--to=normalperson@yhbt.net \
--cc=git@vger.kernel.org \
--cc=torvalds@osdl.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).