mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-03 10:21:46 +02:00
43443: _git: When completing worktrees, show the ref and hash of each worktree.
This commit is contained in:
parent
7ae2be3a2f
commit
b44be21525
2 changed files with 22 additions and 2 deletions
|
@ -1,5 +1,8 @@
|
||||||
2018-09-12 Daniel Shahaf <d.s@daniel.shahaf.name>
|
2018-09-12 Daniel Shahaf <d.s@daniel.shahaf.name>
|
||||||
|
|
||||||
|
* 43443: Completion/Unix/Command/_git: When completing worktrees,
|
||||||
|
show the ref and hash of each worktree.
|
||||||
|
|
||||||
* 43442: Completion/Unix/Command/_git: Break out a helper
|
* 43442: Completion/Unix/Command/_git: Break out a helper
|
||||||
function.
|
function.
|
||||||
|
|
||||||
|
|
|
@ -7561,8 +7561,25 @@ __git_browsers () {
|
||||||
}
|
}
|
||||||
|
|
||||||
__git_worktrees () {
|
__git_worktrees () {
|
||||||
_wanted directories expl 'working tree' compadd -S ' ' -f -M 'r:|/=* r:|=*' \
|
local -a records=( ${(ps.\n\n.)"$(_call_program directories git worktree list --porcelain)"} )
|
||||||
${${(M)${(f)"$(_call_program directories git worktree list --porcelain)"}:#worktree*}#* }
|
local -a directories descriptions
|
||||||
|
local i hash branch
|
||||||
|
for i in $records; do
|
||||||
|
directories+=( ${${i%%$'\n'*}#worktree } )
|
||||||
|
hash=${${${"${(f)i}"[2]}#HEAD }[1,9]}
|
||||||
|
branch=${${"${(f)i}"[3]}#branch refs/heads/}
|
||||||
|
|
||||||
|
# Simulate the non-porcelain output
|
||||||
|
if [[ $branch == detached ]]; then
|
||||||
|
# TODO: show a ref that points at $hash here, like vcs_info does?
|
||||||
|
branch="(detached HEAD)"
|
||||||
|
else
|
||||||
|
branch="[$branch]"
|
||||||
|
fi
|
||||||
|
|
||||||
|
descriptions+=( "${directories[-1]}"$'\t'"$hash $branch" )
|
||||||
|
done
|
||||||
|
_wanted directories expl 'working tree' compadd -ld descriptions -S ' ' -f -M 'r:|/=* r:|=*' -a directories
|
||||||
}
|
}
|
||||||
|
|
||||||
(( $+functions[__git_difftools] )) ||
|
(( $+functions[__git_difftools] )) ||
|
||||||
|
|
Loading…
Reference in a new issue