completion: make refs completion consistent for local and remote repos
For a local repository the __git_refs() completion helper function lists refs under 'refs/(tags|heads|remotes)/', plus some special refs like HEAD and ORIG_HEAD. For a remote repository, however, it lists all refs. Fix this inconsistency by specifying refs filter patterns for 'git ls-remote' to only list refs under 'refs/(tags|heads|remotes)/'. For now this makes it impossible to complete refs outside of 'refs/(tags|heads|remotes)/' in a remote repository, but a followup patch will resurrect that. Signed-off-by: SZEDER Gábor <szeder@ira.uka.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
a31e62629a
commit
abf05987de
@ -616,13 +616,11 @@ __git_refs ()
|
|||||||
fi
|
fi
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
for i in $(git ls-remote "$dir" 2>/dev/null); do
|
for i in $(git ls-remote "$dir" HEAD ORIG_HEAD 'refs/tags/*' 'refs/heads/*' 'refs/remotes/*' 2>/dev/null); do
|
||||||
case "$is_hash,$i" in
|
case "$is_hash,$i" in
|
||||||
y,*) is_hash=n ;;
|
y,*) is_hash=n ;;
|
||||||
n,*^{}) is_hash=y ;;
|
n,*^{}) is_hash=y ;;
|
||||||
n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
|
n,refs/*) is_hash=y; echo "${i#refs/*/}" ;;
|
||||||
n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
|
|
||||||
n,refs/remotes/*) is_hash=y; echo "${i#refs/remotes/}" ;;
|
|
||||||
n,*) is_hash=y; echo "$i" ;;
|
n,*) is_hash=y; echo "$i" ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
Reference in New Issue
Block a user