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

Re: [PATCH 13/14] completion: add default options

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Jun 22, 2019, 04:36 UTC
Message-ID
<CAMP44s0+OoqhXHX1BD7Gw-0GqgyKYPw4GzhNr9n2pOfxjWcMYg@mail.gmail.com>
In-Reply-To
<CACsJy8AATA-7Z+HsA80NQ2j4Z9JeuSYXiBZLi=7FopzfLY1R+w@mail.gmail.com>
On Fri, Jun 21, 2019 at 10:02 PM Duy Nguyen <pclouds@gmail.com> wrote:
Show 31 quoted lines
>
> On Sat, Jun 22, 2019 at 5:31 AM Felipe Contreras
> <felipe.contreras@gmail.com> wrote:
> >
> > Versions of Git older than v2.17 don't know about
> > --git-completion-helper, so provide some defaults for them.
> >
> > Also, some commands fail if there's no Git repository available.
> >
> > Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> > ---
> >  contrib/completion/git-completion.bash | 97 +++++++++++++++++++++++++-
> >  t/t9902-completion.sh                  |  4 +-
> >  2 files changed, 98 insertions(+), 3 deletions(-)
> >
> > diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> > index d3ee6c7dc2..922ba5f925 100644
> > --- a/contrib/completion/git-completion.bash
> > +++ b/contrib/completion/git-completion.bash
> > @@ -377,6 +377,100 @@ else
> >         unset $(compgen -v __gitcomp_builtin_)
> >  fi
> >
> > +__gitcomp_builtin_add_default=" --dry-run --verbose --interactive --patch --edit --force --update --renormalize --intent-to-add --all --ignore-
> removal --refresh --ignore-errors --ignore-missing --chmod=
> --no-dry-run -- --no-verbose --no-interactive --no-patch --no-edit
> --no-force --no-update --no-renormalize --no-intent-to-add --no-all
> --no-ignore-removal --no-refresh --no-ignore-errors
> --no-ignore-missing --no-chmod"
>
> And who's going to keep these uptodate?
The same people that kept them up-to-date before git-completion-helper.
> If you do this, might as well delete --git-completion-helper

They serve two different purposes. Say you install the completion of Git v2.22, but a while later you have Git v2.25; you will get the updated commands thanks to git-completion-helper, and all the __gitcomp_builtin_*_default will be ignored.

Granted; that's not the typical situation, as many people get the Git completion through their distribution in tandem with their Git version. But remember that these completion scripts are part of contrib; they are not part of official Git (`make install` doesn't install them).

When a) most people have a version of git that has git-completion-helper, and b) most of the issues running commands outside of a Git repo are resolved, they could be removed. But right now they do serve a purpose.

Show 5 quoted lines
> A more acceptable option might be regenerate git-completion.bash and
> run --git-completion-helper to generate these, or make
> git-completion.bash source a generated file. But that might need some
> more build infrastructure, and people who just one to copy the file
> might not like it.

Indeed, I wrote a script to generate these, but I manually copied them. I could write a script that automatically generates this file if it's agreed that this is indeed the way we want to go.

But even if these were not up-to-date--as historically has been the case for most options--and a) you are running a version of Git that doesn't have git-completion-helper, or b) you run a command that requires a Git repo; it's better to get outdated options than to get *nothing*, which is what we get now.

Cheers.
-- 
Felipe Contreras
Previous: Duy NguyenNext: Junio C Hamano
Message 20 of 58 in “completion: a bunch of updates”
  1. 00/14 completion: a bunch of updatesFelipe Contreras, Jun 21, 2019
  2. 01/14 completion: zsh: fix __gitcomp_direct()Felipe Contreras, Jun 21, 2019
  3. Felipe ContrerasJun 22, 2019
  4. 02/14 completion: zsh: fix for directories with spacesFelipe Contreras, Jun 21, 2019
  5. 03/14 completion: remove zsh hackFelipe Contreras, Jun 21, 2019
  6. 04/14 completion: zsh: improve main function selectionFelipe Contreras, Jun 21, 2019
  7. 05/14 completion: prompt: fix color for ZshFelipe Contreras, Jun 21, 2019
  8. 08/14 completion: bash: remove old compat wrappersFelipe Contreras, Jun 21, 2019
  9. 07/14 completion: zsh: update installation instructionsFelipe Contreras, Jun 21, 2019
  10. 06/14 completion: bash: cleanup cygwin checkFelipe Contreras, Jun 21, 2019
  11. 09/14 completion: bash: remove zsh wrapperFelipe Contreras, Jun 21, 2019
  12. 11/14 test: completion: tests for __gitcomp regressionFelipe Contreras, Jun 21, 2019
  13. Junio C HamanoJul 3, 2019
  14. SZEDER GáborJul 3, 2019
  15. 10/14 completion: zsh: trivial cleanupsFelipe Contreras, Jun 21, 2019
  16. 12/14 test: completion: use global configFelipe Contreras, Jun 21, 2019
  17. Junio C HamanoJul 3, 2019
  18. 13/14 completion: add default optionsFelipe Contreras, Jun 21, 2019
  19. Duy NguyenJun 22, 2019
  20. Felipe ContrerasJun 22, 2019
  21. Junio C HamanoJun 24, 2019
  22. Felipe ContrerasJun 25, 2019
  23. Duy NguyenJun 25, 2019
  24. 14/14 completion: add default merge strategiesFelipe Contreras, Jun 21, 2019
  25. Junio C HamanoJun 24, 2019
  26. Felipe ContrerasJun 25, 2019
  27. Junio C HamanoJun 25, 2019
  28. SZEDER GáborJul 3, 2019
  29. Junio C HamanoJul 3, 2019
  30. SZEDER GáborJul 3, 2019
  31. Felipe ContrerasOct 25, 2020
  32. Felipe ContrerasOct 25, 2020
  33. Junio C HamanoOct 27, 2020
  34. Felipe ContrerasOct 27, 2020
  35. Junio C HamanoOct 27, 2020
  36. Felipe ContrerasOct 28, 2020
  37. Stefan HallerOct 28, 2020
  38. Felipe ContrerasOct 28, 2020
  39. Stefan HallerOct 28, 2020
  40. Junio C HamanoOct 29, 2020
  41. Junio C HamanoOct 29, 2020
  42. Felipe ContrerasNov 2, 2020
  43. Junio C HamanoNov 3, 2020
  44. Felipe ContrerasNov 4, 2020
  45. Junio C HamanoNov 4, 2020
  46. Felipe ContrerasNov 5, 2020
  47. Junio C HamanoNov 5, 2020
  48. Stefan HallerOct 30, 2020
  49. Junio C HamanoOct 30, 2020
  50. Felipe ContrerasNov 2, 2020
  51. Aaron SchrabNov 2, 2020
  52. Junio C HamanoNov 3, 2020
  53. Felipe ContrerasNov 3, 2020
  54. Felipe ContrerasNov 3, 2020
  55. Stefan HallerNov 3, 2020
  56. Junio C HamanoNov 3, 2020
  57. Stefan HallerNov 3, 2020
  58. Felipe ContrerasNov 2, 2020

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.