1
0
mirror of https://github.com/git/git.git synced 2024-10-21 09:18:12 +02:00

Merge branch 'cp/completion-negative-refs'

The command-line completion script (in contrib/) learned to
complete "git cmd ^mas<HT>" to complete the negative end of
reference to "git cmd ^master".

* cp/completion-negative-refs:
  completion: support excluding refs
This commit is contained in:
Junio C Hamano 2016-10-10 14:03:49 -07:00
commit a229a30f8a

@ -338,7 +338,7 @@ __git_tags ()
__git_refs () __git_refs ()
{ {
local i hash dir="$(__gitdir "${1-}")" track="${2-}" local i hash dir="$(__gitdir "${1-}")" track="${2-}"
local format refs local format refs pfx
if [ -d "$dir" ]; then if [ -d "$dir" ]; then
case "$cur" in case "$cur" in
refs|refs/*) refs|refs/*)
@ -347,14 +347,15 @@ __git_refs ()
track="" track=""
;; ;;
*) *)
[[ "$cur" == ^* ]] && pfx="^"
for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do
if [ -e "$dir/$i" ]; then echo $i; fi if [ -e "$dir/$i" ]; then echo $pfx$i; fi
done done
format="refname:short" format="refname:short"
refs="refs/tags refs/heads refs/remotes" refs="refs/tags refs/heads refs/remotes"
;; ;;
esac esac
git --git-dir="$dir" for-each-ref --format="%($format)" \ git --git-dir="$dir" for-each-ref --format="$pfx%($format)" \
$refs $refs
if [ -n "$track" ]; then if [ -n "$track" ]; then
# employ the heuristic used by git checkout # employ the heuristic used by git checkout