git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/6] gitopt: a new command-line option parser for git

From
EWEric Wong <normalperson@yhbt.net>
Date
May 9, 2006, 19:39 UTC
Message-ID
<20060509193932.GB3676@localdomain>
In-Reply-To
<7v8xpb73sq.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> wrote:
Show 19 quoted lines
> Timo Hirvonen <tihirvon@gmail.com> writes:
> 
> > Eric Wong <normalperson@yhbt.net> wrote:
> >
> >>  * unbundling of short options: -uC20n20z => -u -C20 -n20 -z
> >
> > Does anyone ever use this?  I think this makes sense only for flags that
> > don't have parameters but that would create an ugly special case. Is it
> > too hard to type "-u -C=20 -n=20 -z"?
> 
> I can already hear in my head that people would start talking
> about "git understands insane abbeviations of options".  It
> might be unambiguous, but that does not change it is a bit on
> the insane side.  People would probably expect -nuz can be split
> into -n -u -z, and the current handcrafted mess (although it is
> more obvious and easy to work with when reading and maintaining
> the existing code) is not abbreviation friendly, which we would
> want to do something about.  But I think squashing options with
> parameters together is going a bit too far.

I think numeric parameters are unambiguous when bundled. I'm used to things like `diff -ru10p` working, *shrug*

Non-numeric parameters can only be used if the option is at the end of the bundled string:

git commit -sam'this is my commit message'  would work
git commit -m'say hello' would also work

but git commit -mas'this is my commit message' would not work as intended (where user wanted -a -s, too)

> > --with-r => --patch-with-raw works great
> 
> I personally think this also is too much.

There are (currently) two types of abbreviations, one is the prefix one used commonly in shell scripts: -e|--e|--ed|--edi|--edit. I think this should always be supported as most of our shell scripts already do.

The other one tokenizes on '-' first and looks for a prefix match after each '-'. I'd like to make that at least optional:

diff --git a/gitopt.c b/gitopt.c
index 056e163..9ca6025 100644
--- a/gitopt.c
+++ b/gitopt.c
gitopt.c
@@ -427,7 +427,7 @@ static void fallback_long(const struct o
        }
 
        /* ok, try harder, based on tokenization on '-' */
-       if (found < 0) {
+       if (found < 0 && getenv("GIT_ABBREV_HARDER")) {
                for (i = 0; ost[i].l || ost[i].s; i++) {
                        s = &(ost[i]);
                        if (s->l && opt_token_match(s,cur)) {
-- 
Eric Wong
Previous: Junio C HamanoNext: Eric Wong
Message 7 of 13 in “gitopt: a new command-line option parser for git”
  1. 1/6 gitopt: a new command-line option parser for gitEric Wong, May 9, 2006
  2. 2/6 update-index: convert to using gitoptEric Wong, May 9, 2006
  3. 3/6 ls-tree: convert to gitoptEric Wong, May 9, 2006
  4. 4/6 ls-files: convert to using gitoptEric Wong, May 9, 2006
  5. Timo HirvonenMay 9, 2006
  6. Junio C HamanoMay 9, 2006
  7. Eric WongMay 9, 2006
  8. Eric WongMay 9, 2006
  9. Timo HirvonenMay 9, 2006
  10. Junio C HamanoMay 9, 2006
  11. Timo HirvonenMay 9, 2006
  12. Junio C HamanoMay 9, 2006
  13. Timo HirvonenMay 9, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.