Subject: [PATCH] bash completion: Fix the . -> .. revision range completion

From: Petr Baudis <[email-masked]>
Date: Sun, 13 Jul 2008 13:19:58 +0200

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 <[email-masked]>
---

 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)"