diff options
author | Chris Packham <judge.packham@gmail.com> | 2016-08-24 20:41:52 +1200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-08-24 09:51:05 -0700 |
commit | 49416ad22aa917178f306859a5bab60311166a9f (patch) | |
tree | 9cc948f0022e7716ae9f169e998b3f335d3b634c | |
parent | e0c1ceafc5bece92d35773a75fff59497e1d9bd5 (diff) | |
download | git-49416ad22aa917178f306859a5bab60311166a9f.tar.gz git-49416ad22aa917178f306859a5bab60311166a9f.tar.xz |
completion: support excluding refs
Allow completion of refs with a ^ prefix. This allows completion of
commands like 'git log HEAD ^origin/master'.
Signed-off-by: Chris Packham <judge.packham@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | contrib/completion/git-completion.bash | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index bd25b0a89..eb8a3d4aa 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -338,7 +338,7 @@ __git_tags () __git_refs () { local i hash dir="$(__gitdir "${1-}")" track="${2-}" - local format refs + local format refs pfx if [ -d "$dir" ]; then case "$cur" in refs|refs/*) @@ -347,14 +347,15 @@ __git_refs () track="" ;; *) + [[ "$cur" == ^* ]] && pfx="^" 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 format="refname:short" refs="refs/tags refs/heads refs/remotes" ;; esac - git --git-dir="$dir" for-each-ref --format="%($format)" \ + git --git-dir="$dir" for-each-ref --format="$pfx%($format)" \ $refs if [ -n "$track" ]; then # employ the heuristic used by git checkout |