summaryrefslogtreecommitdiff
path: root/Completion/Unix/Command/_git
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Unix/Command/_git')
-rw-r--r--Completion/Unix/Command/_git9
1 files changed, 8 insertions, 1 deletions
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 5d656569a..a6e75c64a 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -1529,6 +1529,13 @@ _git-branch () {
}
__git_zstyle_default ':completion::complete:git-branch:delete-argument-rest:*' ignore-line yes
+(( $+functions[__git_is_treeish] )) ||
+__git_is_treeish () {
+ local sha1
+ sha1="$(git rev-parse $1)"
+ [[ "$(git cat-file -t "${sha1}^{tree}" 2> /dev/null)" == tree ]]
+}
+
# TODO: __git_tree_ishs is just stupid. It should be giving us a list of tags
# and perhaps also allow all that just with ^{tree} and so on. Not quite sure
# how to do that, though.
@@ -1566,7 +1573,7 @@ _git-checkout () {
#What's the variable that holds the tree-ish argument? Is it even reliably possible?
case $state in
(files)
- if [[ -n $line[1] ]]; then
+ if [[ -n $line[1] ]] && __git_is_treeish $line[1]; then
__git_tree_files . $line[1] && ret=0
else
__git_cached_files && ret=0