Skip to content

Commit 07d9382

Browse files
authored
Merge pull request #484 from akinomyoga/prompt-git
lib/git: Fix problems caused by uses of Zsh features
2 parents 1e2b292 + 1dfbd39 commit 07d9382

18 files changed

+227
-212
lines changed

completions/gh.completion.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ EOF
322322
format=${format//\p/\2}
323323
format=${format//\o/\3}
324324
fi
325-
command git config --get-regexp 'remote\.[^.]*\.url' |
325+
_omb_prompt_git config --get-regexp 'remote\.[^.]*\.url' |
326326
grep -E ' ((https?|git)://|git@)github\.com[:/][^:/]+/[^/]+$' |
327327
sed -E 's#^remote\.([^.]+)\.url +.+[:/](([^/]+)/[^.]+)(\.git)?$#'"$format"'#'
328328
}
@@ -332,12 +332,12 @@ EOF
332332
function __hub_heads {
333333
local i remote repo branch dir=$(__gitdir)
334334
if [ -d "$dir" ]; then
335-
command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
335+
_omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
336336
"refs/heads/"
337337
for i in $(__hub_github_repos); do
338338
remote=${i%%:*}
339339
repo=${i#*:}
340-
command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
340+
_omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
341341
"refs/remotes/${remote}/" | while read branch; do
342342
echo "${repo}:${branch#${remote}/}"
343343
done
@@ -351,11 +351,11 @@ EOF
351351
function __hub_revlist {
352352
local i remote=${1:-origin} dir=$(__gitdir)
353353
if [ -d "$dir" ]; then
354-
command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
354+
_omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
355355
"refs/remotes/${remote}/" | while read i; do
356356
echo "${i#${remote}/}"
357357
done
358-
command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
358+
_omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
359359
"refs/tags/"
360360
fi
361361
}

completions/git_flow.completion.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,17 @@ __git_flow_feature ()
107107

108108
__git_flow_list_features ()
109109
{
110-
git flow feature list 2> /dev/null | tr -d ' |*'
110+
_omb_prompt_git flow feature list 2> /dev/null | tr -d ' |*'
111111
}
112112

113113
__git_flow_list_remote_features ()
114114
{
115-
git branch -r 2> /dev/null | grep "origin/$(__git_flow_feature_prefix)" | awk '{ sub(/^origin\/$(__git_flow_feature_prefix)/, "", $1); print }'
115+
_omb_prompt_git branch -r 2> /dev/null | grep "origin/$(__git_flow_feature_prefix)" | awk '{ sub(/^origin\/$(__git_flow_feature_prefix)/, "", $1); print }'
116116
}
117117

118118
__git_flow_feature_prefix ()
119119
{
120-
git config gitflow.prefix.feature 2> /dev/null || echo "feature/"
120+
_omb_prompt_git config gitflow.prefix.feature 2> /dev/null || echo "feature/"
121121
}
122122

123123
__git_flow_release ()
@@ -143,7 +143,7 @@ __git_flow_release ()
143143

144144
__git_flow_list_releases ()
145145
{
146-
git flow release list 2> /dev/null
146+
_omb_prompt_git flow release list 2> /dev/null
147147
}
148148

149149
__git_flow_hotfix ()
@@ -168,7 +168,7 @@ __git_flow_hotfix ()
168168

169169
__git_flow_list_hotfixes ()
170170
{
171-
git flow hotfix list 2> /dev/null
171+
_omb_prompt_git flow hotfix list 2> /dev/null
172172
}
173173

174174
# temporarily wrap __git_find_on_cmdline() for backwards compatibility

completions/git_flow_avh.completion.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ __git_flow_prefix ()
454454
{
455455
case "$1" in
456456
feature|release|hotfix|support)
457-
git config "gitflow.prefix.$1" 2> /dev/null || echo "$1/"
457+
_omb_prompt_git config "gitflow.prefix.$1" 2> /dev/null || echo "$1/"
458458
return
459459
;;
460460
esac
@@ -464,23 +464,23 @@ __git_flow_list_local_branches ()
464464
{
465465
if [ -n "$1" ]; then
466466
local prefix="$(__git_flow_prefix $1)"
467-
git for-each-ref --shell --format="ref=%(refname:short)" refs/heads/$prefix | \
467+
_omb_prompt_git for-each-ref --shell --format="ref=%(refname:short)" refs/heads/$prefix | \
468468
while read -r entry; do
469469
eval "$entry"
470470
ref="${ref#$prefix}"
471471
echo "$ref"
472472
done | sort
473473
else
474-
git for-each-ref --format="ref=%(refname:short)" refs/heads/ | sort
474+
_omb_prompt_git for-each-ref --format="ref=%(refname:short)" refs/heads/ | sort
475475

476476
fi
477477
}
478478

479479
__git_flow_list_remote_branches ()
480480
{
481481
local prefix="$(__git_flow_prefix $1)"
482-
local origin="$(git config gitflow.origin 2> /dev/null || echo "origin")"
483-
git for-each-ref --shell --format='%(refname:short)' refs/remotes/$origin/$prefix | \
482+
local origin="$(_omb_prompt_git config gitflow.origin 2> /dev/null || echo "origin")"
483+
_omb_prompt_git for-each-ref --shell --format='%(refname:short)' refs/remotes/$origin/$prefix | \
484484
while read -r entry; do
485485
eval "$entry"
486486
ref="${ref##$prefix}"
@@ -490,17 +490,17 @@ __git_flow_list_remote_branches ()
490490

491491
__git_flow_list_branches ()
492492
{
493-
local origin="$(git config gitflow.origin 2> /dev/null || echo "origin")"
493+
local origin="$(_omb_prompt_git config gitflow.origin 2> /dev/null || echo "origin")"
494494
if [ -n "$1" ]; then
495495
local prefix="$(__git_flow_prefix $1)"
496-
git for-each-ref --shell --format="ref=%(refname:short)" refs/heads/$prefix refs/remotes/$origin/$prefix | \
496+
_omb_prompt_git for-each-ref --shell --format="ref=%(refname:short)" refs/heads/$prefix refs/remotes/$origin/$prefix | \
497497
while read -r entry; do
498498
eval "$entry"
499499
ref="${ref##$prefix}"
500500
echo "$ref"
501501
done | sort
502502
else
503-
git for-each-ref --format="%(refname:short)" refs/heads/ refs/remotes/$origin | sort
503+
_omb_prompt_git for-each-ref --format="%(refname:short)" refs/heads/ refs/remotes/$origin | sort
504504
fi
505505
}
506506

completions/hub.completion.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ EOF
324324
format=${format//\p/\2}
325325
format=${format//\o/\3}
326326
fi
327-
command git config --get-regexp 'remote\.[^.]*\.url' |
327+
_omb_prompt_git config --get-regexp 'remote\.[^.]*\.url' |
328328
grep -E ' ((https?|git)://|git@)github\.com[:/][^:/]+/[^/]+$' |
329329
sed -E 's#^remote\.([^.]+)\.url +.+[:/](([^/]+)/[^.]+)(\.git)?$#'"$format"'#'
330330
}
@@ -334,12 +334,12 @@ EOF
334334
function __hub_heads {
335335
local i remote repo branch dir=$(__gitdir)
336336
if [ -d "$dir" ]; then
337-
command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
337+
_omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
338338
"refs/heads/"
339339
for i in $(__hub_github_repos); do
340340
remote=${i%%:*}
341341
repo=${i#*:}
342-
command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
342+
_omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
343343
"refs/remotes/${remote}/" | while read branch; do
344344
echo "${repo}:${branch#${remote}/}"
345345
done
@@ -353,11 +353,11 @@ EOF
353353
function __hub_revlist {
354354
local i remote=${1:-origin} dir=$(__gitdir)
355355
if [ -d "$dir" ]; then
356-
command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
356+
_omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
357357
"refs/remotes/${remote}/" | while read i; do
358358
echo "${i#${remote}/}"
359359
done
360-
command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
360+
_omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
361361
"refs/tags/"
362362
fi
363363
}

0 commit comments

Comments
 (0)