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

Re: [PATCH] parse-options: don't complete option aliases by default

From
Philippe Blain <levraiphilippeblain@gmail.com>
Date
Jul 16, 2021, 01:31 UTC
Message-ID
<1f41f94a-ebe1-69f0-7631-864cbbd1e1a0@gmail.com>
In-Reply-To
<8735sfzgkg.fsf@evledraar.gmail.com>
Hi Ævar,
Le 2021-07-15 à 12:16, Ævar Arnfjörð Bjarmason a écrit :
Show 20 quoted lines
> 
> 
> I'm a bit biased here since I like --recursive better, but let's not
> drag that whole argument up again. I don't find the argument in
> bb62e0a99fc (clone: teach --recurse-submodules to optionally take a
> pathspec, 2017-03-17) convincing enough to have moved such a prominent
> use-case to a longer option name.
> 
> But, water under the bridge. Aside from that:
> 
> For me a Google search for "git clone --recursive" is ~40k results, but
> "git clone --recurse-submodules". The former links to various
> discussions/docs/stackoverflow answers, often --recurse-submodules isn't
> mentioned at all or as an aside.
> 
> I think it's unfortunate that we:
> 
>   1. Conflate whether something shows up in completion v.s. the
>      help. Given its prominence and that "git clone -h" is ~50 lines why
>      not note --recursive there.

As far as I understand (and tested), '--recursive' was listed in the short help but not the completion before bb62e0a99f (clone: teach --recurse-submodules to optionally take a pathspec, 2017-03-17). At the time the completion did not use '--git-completion-helper' and only '--recurse-submodules' was listed (since 5f072e0017 (completion: add option '--recurse-submodules' to 'git clone', 2016-07-27)).

Starting from bb62e0a99f, it was not listed in the short help (because of PARSE_OPT_HIDDEN) nor the completion (because it was still not listed).

Then starting from 5c387428f1 (parse-options: don't emit "ambiguous option" for aliases, 2019-04-29), it started being listed in the short help AND the completion again; in the short help because of the new code in usage_with_options_internal and in the completion because of the way preprocess_options is implemented, and at that time '--git-completion-helper' was used for '_git_clone'.

After my patch, it would still be listed in the short help, as "alias of --recurse-submodules", but would not be listed by the completion (unless GIT_COMPLETION_SHOW_ALL is set).

> 
>   2. Don't have the completion aware of these aliases, i.e. "git clone
>      --rec<TAB>" before your chance offers a completion of both, that sucks,
>      we should fully complete the non-alias instead.
Indeed. That's my main motivation.
Show 9 quoted lines
> 
>   3. Making it PARSE_OPT_HIDDEN "solves" #2 at the cost of hiding it in
>      "git help -h", and now this won't work, but did before:
> 
>          git clone --recursi<TAB>
> 
>      I.e. even if we didn't want to do #2 *and* wanted to hide it in the
>      usage output surely completing an unmbigous prefix is better, even
>      if it's a hidden option?

I agree that with my patch 'git clone --recursi<TAB>' does not complete to '--recursive' (unless you've set GIT_COMPLETION_SHOW_ALL). But I'm not sure it's that big of a deal (after all if you typed this far you only have two letters left :P) But '--rec' will be sufficient to complete to '--recurse-submoduele', so it's even less letters to type.

But this has nothing to do with PARSE_OPT_HIDDEN ('--recurse-submodules' is not hidden and aliases are not hidden either). So I'm not sure what you mean...

Show 9 quoted lines
> 
> Per-se none of this is a blocker or "we must fix this first" for this
> particular change, we have this in many existing cases.
> 
> I daresay there's no other alias that's in as wide a use in the wild, so
> we should think about this one particularly carefully though.
> 
> It's not fully clear from your commit message which of 1-3 you're aiming
> for, I think it's more of the "discourage its use".
As I wrote it's mainly #2, I'll update the commit message to be clearer.
Show 9 quoted lines
> 
> Sure, fair enough, but PARSE_OPT_HIDDEN is not a 1=1 mapping to that,
> and can often lead to more user confusion.
> 
> E.g. the user has used --recursive for years, but can't even find it in
> -h (I also think it's a mistake to have entirely removed it from the
> docs, even if one agrees with its "deprecation" I'd say we should keep
> some "used to be called --recursive" note there).
> 

Yeah, maybe it should have stayed in the docs. Again, my patch does not remove it from the short help.

Thanks for you comments!:)
Philippe.
Previous: Philippe BlainNext: Felipe Contreras
Message 6 of 9 in “parse-options: don't complete option aliases by default”
  1. parse-options: don't complete option aliases by defaultPhilippe Blain via GitGitGadget, Jul 15, 2021
  2. Ævar Arnfjörð BjarmasonJul 15, 2021
  3. Felipe ContrerasJul 15, 2021
  4. Junio C HamanoJul 15, 2021
  5. Philippe BlainJul 16, 2021
  6. Philippe BlainJul 16, 2021
  7. Felipe ContrerasJul 15, 2021
  8. Philippe BlainJul 16, 2021
  9. parse-options: don't complete option aliases by defaultPhilippe Blain via GitGitGadget, Jul 16, 2021

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.