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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx>
---

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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux