On Fri, Jun 21, 2019 at 10:02 PM Duy Nguyen <pclouds@xxxxxxxxx> wrote: > > On Sat, Jun 22, 2019 at 5:31 AM Felipe Contreras > <felipe.contreras@xxxxxxxxx> 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@xxxxxxxxx> > > --- > > 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. > 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