[git] Move git-action to its own autoloadable file
instead of redefining the function constantly inside git-info.
This commit is contained in:
vanhempi
f11bb607c5
commit
539f8ae8df
3 muutettua tiedostoa jossa 81 lisäystä ja 82 poistoa
|
@ -1,3 +1,4 @@
|
|||
# vim:et sts=2 sw=2 ft=zsh
|
||||
# Prints the first non-empty string in the arguments array.
|
||||
for arg in ${argv}; do
|
||||
print -n ${arg}
|
||||
|
|
80
modules/git-info/functions/git-action
Tavallinen tiedosto
80
modules/git-info/functions/git-action
Tavallinen tiedosto
|
@ -0,0 +1,80 @@
|
|||
# vim:et sts=2 sw=2 ft=zsh
|
||||
# Gets the Git special action (am, bisect, cherry, merge, rebase).
|
||||
# Borrowed from vcs_info and edited.
|
||||
local git_dir=${$(command git rev-parse --git-dir):A}
|
||||
local action_dir
|
||||
for action_dir in \
|
||||
"${git_dir}/rebase-apply" \
|
||||
"${git_dir}/rebase" \
|
||||
"${git_dir}/../.dotest"
|
||||
do
|
||||
if [[ -d ${action_dir} ]]; then
|
||||
local apply_formatted rebase_formatted
|
||||
zstyle -s ':zim:git-info:action:apply' format 'apply_formatted' || apply_formatted='apply'
|
||||
zstyle -s ':zim:git-info:action:rebase' format 'rebase_formatted' || rebase_formatted='rebase'
|
||||
|
||||
if [[ -f "${action_dir}/rebasing" ]]; then
|
||||
print ${rebase_formatted}
|
||||
elif [[ -f "${action_dir}/applying" ]]; then
|
||||
print ${apply_formatted}
|
||||
else
|
||||
print "${rebase_formatted}/${apply_formatted}"
|
||||
fi
|
||||
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
for action_dir in \
|
||||
"${git_dir}/rebase-merge/interactive" \
|
||||
"${git_dir}/.dotest-merge/interactive"
|
||||
do
|
||||
if [[ -f ${action_dir} ]]; then
|
||||
local rebase_interactive_formatted
|
||||
zstyle -s ':zim:git-info:action:rebase-interactive' format 'rebase_interactive_formatted' || rebase_interactive_formatted='rebase-interactive'
|
||||
print ${rebase_interactive_formatted}
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
for action_dir in \
|
||||
"${git_dir}/rebase-merge" \
|
||||
"${git_dir}/.dotest-merge"
|
||||
do
|
||||
if [[ -d ${action_dir} ]]; then
|
||||
local rebase_merge_formatted
|
||||
zstyle -s ':zim:git-info:action:rebase-merge' format 'rebase_merge_formatted' || rebase_merge_formatted='rebase-merge'
|
||||
print ${rebase_merge_formatted}
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -f "${git_dir}/MERGE_HEAD" ]]; then
|
||||
local merge_formatted
|
||||
zstyle -s ':zim:git-info:action:merge' format 'merge_formatted' || merge_formatted='merge'
|
||||
print ${merge_formatted}
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ -f "${git_dir}/CHERRY_PICK_HEAD" ]]; then
|
||||
if [[ -d "${git_dir}/sequencer" ]]; then
|
||||
local cherry_pick_sequence_formatted
|
||||
zstyle -s ':zim:git-info:action:cherry-pick-sequence' format 'cherry_pick_sequence_formatted' || cherry_pick_sequence_formatted='cherry-pick-sequence'
|
||||
print ${cherry_pick_sequence_formatted}
|
||||
else
|
||||
local cherry_pick_formatted
|
||||
zstyle -s ':zim:git-info:action:cherry-pick' format 'cherry_pick_formatted' || cherry_pick_formatted='cherry-pick'
|
||||
print ${cherry_pick_formatted}
|
||||
fi
|
||||
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ -f "${git_dir}/BISECT_LOG" ]]; then
|
||||
local bisect_formatted
|
||||
zstyle -s ':zim:git-info:action:bisect' format 'bisect_formatted' || bisect_formatted='bisect'
|
||||
print ${bisect_formatted}
|
||||
return 0
|
||||
fi
|
||||
|
||||
return 1
|
|
@ -31,88 +31,6 @@ fi
|
|||
local action_format action_formatted
|
||||
zstyle -s ':zim:git-info:action' format 'action_format'
|
||||
if [[ -n ${action_format} ]]; then
|
||||
# Gets the Git special action (am, bisect, cherry, merge, rebase).
|
||||
# Borrowed from vcs_info and edited.
|
||||
git-action() {
|
||||
local git_dir=${$(command git rev-parse --git-dir):A}
|
||||
local action_dir
|
||||
for action_dir in \
|
||||
"${git_dir}/rebase-apply" \
|
||||
"${git_dir}/rebase" \
|
||||
"${git_dir}/../.dotest"
|
||||
do
|
||||
if [[ -d ${action_dir} ]]; then
|
||||
local apply_formatted rebase_formatted
|
||||
zstyle -s ':zim:git-info:action:apply' format 'apply_formatted' || apply_formatted='apply'
|
||||
zstyle -s ':zim:git-info:action:rebase' format 'rebase_formatted' || rebase_formatted='rebase'
|
||||
|
||||
if [[ -f "${action_dir}/rebasing" ]]; then
|
||||
print ${rebase_formatted}
|
||||
elif [[ -f "${action_dir}/applying" ]]; then
|
||||
print ${apply_formatted}
|
||||
else
|
||||
print "${rebase_formatted}/${apply_formatted}"
|
||||
fi
|
||||
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
for action_dir in \
|
||||
"${git_dir}/rebase-merge/interactive" \
|
||||
"${git_dir}/.dotest-merge/interactive"
|
||||
do
|
||||
if [[ -f ${action_dir} ]]; then
|
||||
local rebase_interactive_formatted
|
||||
zstyle -s ':zim:git-info:action:rebase-interactive' format 'rebase_interactive_formatted' || rebase_interactive_formatted='rebase-interactive'
|
||||
print ${rebase_interactive_formatted}
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
for action_dir in \
|
||||
"${git_dir}/rebase-merge" \
|
||||
"${git_dir}/.dotest-merge"
|
||||
do
|
||||
if [[ -d ${action_dir} ]]; then
|
||||
local rebase_merge_formatted
|
||||
zstyle -s ':zim:git-info:action:rebase-merge' format 'rebase_merge_formatted' || rebase_merge_formatted='rebase-merge'
|
||||
print ${rebase_merge_formatted}
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -f "${git_dir}/MERGE_HEAD" ]]; then
|
||||
local merge_formatted
|
||||
zstyle -s ':zim:git-info:action:merge' format 'merge_formatted' || merge_formatted='merge'
|
||||
print ${merge_formatted}
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ -f "${git_dir}/CHERRY_PICK_HEAD" ]]; then
|
||||
if [[ -d "${git_dir}/sequencer" ]]; then
|
||||
local cherry_pick_sequence_formatted
|
||||
zstyle -s ':zim:git-info:action:cherry-pick-sequence' format 'cherry_pick_sequence_formatted' || cherry_pick_sequence_formatted='cherry-pick-sequence'
|
||||
print ${cherry_pick_sequence_formatted}
|
||||
else
|
||||
local cherry_pick_formatted
|
||||
zstyle -s ':zim:git-info:action:cherry-pick' format 'cherry_pick_formatted' || cherry_pick_formatted='cherry-pick'
|
||||
print ${cherry_pick_formatted}
|
||||
fi
|
||||
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ -f "${git_dir}/BISECT_LOG" ]]; then
|
||||
local bisect_formatted
|
||||
zstyle -s ':zim:git-info:action:bisect' format 'bisect_formatted' || bisect_formatted='bisect'
|
||||
print ${bisect_formatted}
|
||||
return 0
|
||||
fi
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
local action=$(git-action)
|
||||
if [[ -n ${action} ]]; then
|
||||
zformat -f action_formatted ${action_format} "s:${action}"
|
||||
|
|
Ladataan…
Viittaa uudesa ongelmassa