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

Re: [PATCH] Make builtin-reset.c use parse_options.

From
Pierre Habouzit <madcoder@debian.org>
Date
Mar 3, 2008, 17:07 UTC
Message-ID
<20080303170706.GA23210@artemis.madism.org>
In-Reply-To
<1b46aba20803030607v726a6ba1y49ca8524e09c6eae@mail.gmail.com>
On Mon, Mar 03, 2008 at 02:07:57PM +0000, Carlos Rica wrote:
Show 9 quoted lines
> On Sun, Mar 2, 2008 at 5:18 PM, Junio C Hamano <gitster@pobox.com> wrote:
> >  Although "--h" still favors "--hard" over "--help":
> >
> >         $ ./git-reset --h
> >         HEAD is now at c149184...
> >
> 
> Pierre, is there a way to give preference to --help over --hard
> when someone uses --h in command line?
  The problem is that --help (and --help-all for the matter) are "magic"
arguments that parse-options is not aware of when it deals with
abbreviations.
  I assume the sole way is to always test against --help (--help-all
whom --help is a prefix anyways) for prefixes.
  So basically we should replace the block in parse-options.c:
        if (ambiguous_option)
            ...
        if (abbrev_option)
            return get_value(p, abbrev_option, abbrev_flags);
  with something that basically does:
   ambiguous:
       if (ambiguous_option)
            ...
       if (abbrev_option) {
           if (clashes with --help) {
               ambiguous_option = "help";
               ambiguous_flags = 0;
               goto ambiguous;
           }
           return get_value....
      }

the "if (clashes with --help)" obviously has to be expansed as real code, and should use an array of hardcoded values so that it's extensible if the need arises.

-- 
·O·  Pierre Habouzit
··O                                                madcoder@debian.org
OOO                                                http://www.madism.org
Previous: Carlos RicaNext: Junio C Hamano
Message 6 of 15 in “Make builtin-reset.c use parse_options.”
  1. Make builtin-reset.c use parse_options.Carlos Rica, Mar 1, 2008
  2. Junio C HamanoMar 2, 2008
  3. Carlos RicaMar 2, 2008
  4. Junio C HamanoMar 2, 2008
  5. Carlos RicaMar 3, 2008
  6. Pierre HabouzitMar 3, 2008
  7. Junio C HamanoMar 3, 2008
  8. Pierre HabouzitMar 4, 2008
  9. Johannes SchindelinMar 2, 2008
  10. Alex RiesenMar 2, 2008
  11. Carlos RicaMar 2, 2008
  12. Alex RiesenMar 2, 2008
  13. Carlos RicaMar 2, 2008
  14. Alex RiesenMar 2, 2008
  15. Carlos RicaMar 3, 2008

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.