Skip to content

Commit 1ccb807

Browse files
committed
streamline git command use in hooks
1 parent 0946674 commit 1ccb807

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

hooks/vcs_info-githooks.zsh

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
zstyle -a ":vcs_info:${vcs}:${usercontext}:${rrn}" trackingformats formats || return 0
1414

1515
# Are we on a remote-tracking branch?
16-
remote=${$(git rev-parse --verify ${hook_com[branch]}@{upstream} \
16+
remote=${$($vcs_comm[cmd] rev-parse --verify ${hook_com[branch]}@{upstream} \
1717
--symbolic-full-name 2>/dev/null)/refs\/remotes\/}
1818

1919
if [[ -n ${remote} ]] ; then
20-
ahead=$(git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
21-
behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
20+
ahead=$($vcs_comm[cmd] rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
21+
behind=$($vcs_comm[cmd] rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
2222
if (( ahead && behind )); then
2323
zformat -f tmp $formats[3] a:$ahead b:$behind
2424
elif (( ahead )); then
@@ -40,7 +40,7 @@
4040

4141
if [[ -n $format && -s ${hook_com[base_orig]}/.git/refs/stash ]] ; then
4242
# find number of stashed commits
43-
stashes=$(git stash list 2>/dev/null | wc -l)
43+
stashes=$($vcs_comm[cmd] stash list 2>/dev/null | wc -l)
4444
(( stashes )) || return 0
4545

4646
# add to misc

hooks/vcs_info-lofi.zsh

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ is-at-least 4.3.12 || return
4545

4646
# git has the only detect mechanism that does not set the basedir. sheesh.
4747
if (( $+vcs_comm[gitdir] )); then
48-
hook_com[base]=${PWD%/${$( ${vcs_comm[cmd]} rev-parse --show-prefix )%/##}}
48+
hook_com[base]=${PWD%/${$( ${vcs_comm[cmd]} rev-parse --show-prefix 2>/dev/null )%/##}}
4949
elif (( $+vcs_comm[base] )); then
5050
hook_com[base]=$vcs_comm[basedir]
5151
else

0 commit comments

Comments
 (0)