[PATCH] bash completion: Fix the . -> .. revision range completion
- From
Petr Baudis <pasky@suse.cz>
- Date
- Jul 13, 2008, 11:19 UTC
- Message-ID
- <20080713111847.29801.8969.stgit@localhost>
When Git sees a string with trailing dot on a place where revision range could occur, it will unconditionally append another dot to it to help complete a revision range. However, filespec can usually occur at such a place as well. I have been hitting this all the time lately with
git log git-submodule.<tab>
and the like.
This patch will make Git perform the . -> .. completion in __git_complete_revlist only if there is no filename starting with the entered prefix available. At few places, filename could not occur when calling __git_complete_revlist; however, taking this into account did not seem worth complicating the code further.
Signed-off-by: Petr Baudis <pasky@suse.cz> ---
contrib/completion/git-completion.bash | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 61581fe..fe24b8c 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -325,7 +325,12 @@ __git_complete_revlist () __gitcomp "$(__git_refs)" "$pfx" "$cur" ;; *.) - __gitcomp "$cur." + if ls "$cur"* >/dev/null 2>&1; then + # This is a file, not revision range + __gitcomp "$(__git_refs)" + else + __gitcomp "$cur." + fi ;; *) __gitcomp "$(__git_refs)"