2012-02-01 04:37:51 +00:00
|
|
|
#
|
2012-09-07 03:17:38 +00:00
|
|
|
# Exposes Git repository information via the $git_info associative array.
|
2012-02-01 04:37:51 +00:00
|
|
|
#
|
|
|
|
# Authors:
|
|
|
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
|
|
|
#
|
|
|
|
|
2012-08-28 00:38:23 +00:00
|
|
|
# Gets the Git special action (am, bisect, cherry, merge, rebase).
|
2011-09-05 04:37:36 +00:00
|
|
|
# Borrowed from vcs_info and edited.
|
2012-03-23 18:57:51 +00:00
|
|
|
function _git-action {
|
2011-09-05 04:37:36 +00:00
|
|
|
local action_dir
|
2012-05-06 17:40:11 +00:00
|
|
|
local git_dir="$(git-dir)"
|
2012-10-02 18:18:44 +00:00
|
|
|
local apply_formatted
|
|
|
|
local bisect_formatted
|
|
|
|
local cherry_pick_formatted
|
|
|
|
local cherry_pick_sequence_formatted
|
|
|
|
local merge_formatted
|
|
|
|
local rebase_formatted
|
|
|
|
local rebase_interactive_formatted
|
|
|
|
local rebase_merge_formatted
|
2011-09-05 04:37:36 +00:00
|
|
|
|
|
|
|
for action_dir in \
|
|
|
|
"${git_dir}/rebase-apply" \
|
|
|
|
"${git_dir}/rebase" \
|
2012-08-28 01:34:22 +00:00
|
|
|
"${git_dir}/../.dotest"
|
|
|
|
do
|
2011-09-05 04:37:36 +00:00
|
|
|
if [[ -d "$action_dir" ]] ; then
|
2012-10-02 18:18:44 +00:00
|
|
|
zstyle -s ':prezto:module:git:info:action:apply' format 'apply_formatted' || apply_formatted='apply'
|
|
|
|
zstyle -s ':prezto:module:git:info:action:rebase' format 'rebase_formatted' || rebase_formatted='rebase'
|
|
|
|
|
2011-09-05 04:37:36 +00:00
|
|
|
if [[ -f "${action_dir}/rebasing" ]] ; then
|
2012-10-02 18:18:44 +00:00
|
|
|
print "$rebase_formatted"
|
2011-09-05 04:37:36 +00:00
|
|
|
elif [[ -f "${action_dir}/applying" ]] ; then
|
2012-10-02 18:18:44 +00:00
|
|
|
print "$apply_formatted"
|
2011-09-05 04:37:36 +00:00
|
|
|
else
|
2012-10-02 18:18:44 +00:00
|
|
|
print "${rebase_formatted}/${apply_formatted}"
|
2011-09-05 04:37:36 +00:00
|
|
|
fi
|
2012-08-28 01:34:22 +00:00
|
|
|
|
2011-09-05 04:37:36 +00:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
for action_dir in \
|
|
|
|
"${git_dir}/rebase-merge/interactive" \
|
2012-08-28 01:34:22 +00:00
|
|
|
"${git_dir}/.dotest-merge/interactive"
|
|
|
|
do
|
2011-09-05 04:37:36 +00:00
|
|
|
if [[ -f "$action_dir" ]]; then
|
2012-10-02 18:18:44 +00:00
|
|
|
zstyle -s ':prezto:module:git:info:action:rebase-interactive' format 'rebase_interactive_formatted' || rebase_interactive_formatted='rebase-interactive'
|
|
|
|
print "$rebase_interactive_formatted"
|
2011-09-05 04:37:36 +00:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
for action_dir in \
|
2012-08-28 02:43:07 +00:00
|
|
|
"${git_dir}/rebase-merge" \
|
2012-08-28 01:34:22 +00:00
|
|
|
"${git_dir}/.dotest-merge"
|
|
|
|
do
|
2011-09-05 04:37:36 +00:00
|
|
|
if [[ -d "$action_dir" ]]; then
|
2012-10-02 18:18:44 +00:00
|
|
|
zstyle -s ':prezto:module:git:info:action:rebase-merge' format 'rebase_merge_formatted' || rebase_merge_formatted='rebase-merge'
|
|
|
|
print "$rebase_merge_formatted"
|
2011-09-05 04:37:36 +00:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if [[ -f "${git_dir}/MERGE_HEAD" ]]; then
|
2012-10-02 18:18:44 +00:00
|
|
|
zstyle -s ':prezto:module:git:info:action:merge' format 'merge_formatted' || merge_formatted='merge'
|
|
|
|
print "$merge_formatted"
|
2011-09-05 04:37:36 +00:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -f "${git_dir}/CHERRY_PICK_HEAD" ]]; then
|
2012-08-28 00:38:23 +00:00
|
|
|
if [[ -d "${git_dir}/sequencer" ]] ; then
|
2012-10-02 18:18:44 +00:00
|
|
|
zstyle -s ':prezto:module:git:info:action:cherry-pick-sequence' format 'cherry_pick_sequence_formatted' || cherry_pick_sequence_formatted='cherry-pick-sequence'
|
|
|
|
print "$cherry_pick_sequence_formatted"
|
2012-08-28 00:38:23 +00:00
|
|
|
else
|
2012-10-02 18:18:44 +00:00
|
|
|
zstyle -s ':prezto:module:git:info:action:cherry-pick' format 'cherry_pick_formatted' || cherry_pick_formatted='cherry-pick'
|
|
|
|
print "$cherry_pick_formatted"
|
2012-08-28 00:38:23 +00:00
|
|
|
fi
|
|
|
|
|
2011-09-05 04:37:36 +00:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -f "${git_dir}/BISECT_LOG" ]]; then
|
2012-10-02 18:18:44 +00:00
|
|
|
zstyle -s ':prezto:module:git:info:action:bisect' format 'bisect_formatted' || bisect_formatted='bisect'
|
|
|
|
print "$bisect_formatted"
|
2011-09-05 04:37:36 +00:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# Gets the Git status information.
|
2012-03-23 18:57:51 +00:00
|
|
|
function git-info {
|
2011-09-05 04:37:36 +00:00
|
|
|
# Extended globbing is needed to parse repository status.
|
2011-10-11 02:16:06 +00:00
|
|
|
setopt LOCAL_OPTIONS
|
|
|
|
setopt EXTENDED_GLOB
|
2011-09-05 04:37:36 +00:00
|
|
|
|
|
|
|
local action
|
|
|
|
local action_format
|
|
|
|
local action_formatted
|
|
|
|
local added=0
|
|
|
|
local added_format
|
|
|
|
local added_formatted
|
2012-12-22 14:05:32 +00:00
|
|
|
local ahead=0
|
2012-03-14 22:02:16 +00:00
|
|
|
local ahead_and_behind
|
|
|
|
local ahead_and_behind_cmd
|
2011-09-05 04:37:36 +00:00
|
|
|
local ahead_format
|
|
|
|
local ahead_formatted
|
|
|
|
local ahead_or_behind
|
2012-12-22 14:05:32 +00:00
|
|
|
local behind=0
|
2011-09-05 04:37:36 +00:00
|
|
|
local behind_format
|
|
|
|
local behind_formatted
|
|
|
|
local branch
|
|
|
|
local branch_format
|
|
|
|
local branch_formatted
|
2012-03-14 22:02:16 +00:00
|
|
|
local branch_info
|
2012-04-12 01:21:11 +00:00
|
|
|
local clean
|
|
|
|
local clean_formatted
|
2011-09-05 04:37:36 +00:00
|
|
|
local commit
|
|
|
|
local commit_format
|
2012-03-14 22:02:16 +00:00
|
|
|
local commit_formatted
|
2011-09-05 04:37:36 +00:00
|
|
|
local deleted=0
|
|
|
|
local deleted_format
|
|
|
|
local deleted_formatted
|
2012-03-14 23:13:38 +00:00
|
|
|
local dirty=0
|
|
|
|
local dirty_format
|
2011-09-05 04:37:36 +00:00
|
|
|
local dirty_formatted
|
2012-10-02 01:20:59 +00:00
|
|
|
local ignore_submodules
|
2012-12-22 22:48:19 +00:00
|
|
|
local indexed=0
|
|
|
|
local indexed_format
|
|
|
|
local indexed_formatted
|
2012-04-04 22:55:15 +00:00
|
|
|
local -A info_formats
|
|
|
|
local info_format
|
2011-09-05 04:37:36 +00:00
|
|
|
local modified=0
|
|
|
|
local modified_format
|
|
|
|
local modified_formatted
|
2012-03-14 22:38:32 +00:00
|
|
|
local position
|
|
|
|
local position_format
|
|
|
|
local position_formatted
|
2011-09-05 04:37:36 +00:00
|
|
|
local remote
|
2012-03-14 22:02:16 +00:00
|
|
|
local remote_cmd
|
2011-09-05 04:37:36 +00:00
|
|
|
local remote_format
|
|
|
|
local remote_formatted
|
|
|
|
local renamed=0
|
|
|
|
local renamed_format
|
|
|
|
local renamed_formatted
|
|
|
|
local stashed=0
|
|
|
|
local stashed_format
|
|
|
|
local stashed_formatted
|
2012-03-14 22:02:16 +00:00
|
|
|
local status_cmd
|
2012-12-22 22:48:19 +00:00
|
|
|
local status_mode
|
|
|
|
local unindexed=0
|
|
|
|
local unindexed_format
|
|
|
|
local unindexed_formatted
|
2011-09-05 04:37:36 +00:00
|
|
|
local unmerged=0
|
|
|
|
local unmerged_format
|
|
|
|
local unmerged_formatted
|
|
|
|
local untracked=0
|
|
|
|
local untracked_format
|
|
|
|
local untracked_formatted
|
|
|
|
|
2012-04-04 22:55:15 +00:00
|
|
|
# Clean up previous $git_info.
|
|
|
|
unset git_info
|
|
|
|
typeset -gA git_info
|
2011-09-05 04:37:36 +00:00
|
|
|
|
|
|
|
# Return if not inside a Git repository work tree.
|
2012-03-14 22:02:16 +00:00
|
|
|
if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
|
2011-09-05 04:37:36 +00:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if (( $# > 0 )); then
|
|
|
|
if [[ "$1" == [Oo][Nn] ]]; then
|
|
|
|
git config --bool prompt.showinfo true
|
|
|
|
elif [[ "$1" == [Oo][Ff][Ff] ]]; then
|
|
|
|
git config --bool prompt.showinfo false
|
|
|
|
else
|
2012-01-19 07:28:01 +00:00
|
|
|
print "usage: $0 [ on | off ]" >&2
|
2011-09-05 04:37:36 +00:00
|
|
|
fi
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Return if git-info is disabled.
|
2012-01-21 03:03:17 +00:00
|
|
|
if ! is-true "${$(git config --bool prompt.showinfo):-true}"; then
|
2011-09-05 04:37:36 +00:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2012-02-04 00:12:47 +00:00
|
|
|
# Ignore submodule status.
|
2012-10-02 01:20:59 +00:00
|
|
|
zstyle -s ':prezto:module:git:status:ignore' submodules 'ignore_submodules'
|
2012-02-04 00:12:47 +00:00
|
|
|
|
2012-03-23 01:26:30 +00:00
|
|
|
# Format commit.
|
2012-12-22 14:09:54 +00:00
|
|
|
zstyle -s ':prezto:module:git:info:commit' format 'commit_format'
|
|
|
|
if [[ -n "$commit_format" ]]; then
|
|
|
|
commit="$(git rev-parse HEAD 2> /dev/null)"
|
|
|
|
if [[ -n "$commit" ]]; then
|
|
|
|
zformat -f commit_formatted "$commit_format" "c:$commit"
|
|
|
|
fi
|
2012-03-23 01:26:30 +00:00
|
|
|
fi
|
2011-09-05 04:37:36 +00:00
|
|
|
|
2012-03-14 22:02:16 +00:00
|
|
|
# Format stashed.
|
2012-12-22 14:09:54 +00:00
|
|
|
zstyle -s ':prezto:module:git:info:stashed' format 'stashed_format'
|
|
|
|
if [[ -n "$stashed_format" && -f "$(git-dir)/refs/stash" ]]; then
|
2012-05-06 20:48:33 +00:00
|
|
|
stashed="$(git stash list 2> /dev/null | wc -l | awk '{print $1}')"
|
2012-12-22 14:09:54 +00:00
|
|
|
if [[ -n "$stashed" ]]; then
|
|
|
|
zformat -f stashed_formatted "$stashed_format" "S:$stashed"
|
|
|
|
fi
|
2011-09-05 04:37:36 +00:00
|
|
|
fi
|
|
|
|
|
2012-03-14 22:02:16 +00:00
|
|
|
# Format action.
|
2012-12-22 14:09:54 +00:00
|
|
|
zstyle -s ':prezto:module:git:info:action' format 'action_format'
|
|
|
|
if [[ -n "$action_format" ]]; then
|
|
|
|
action="$(_git-action)"
|
|
|
|
if [[ -n "$action" ]]; then
|
|
|
|
zformat -f action_formatted "$action_format" "s:$action"
|
|
|
|
fi
|
2012-03-14 22:02:16 +00:00
|
|
|
fi
|
2012-03-23 01:26:30 +00:00
|
|
|
|
2012-12-22 14:09:54 +00:00
|
|
|
# Get the branch.
|
|
|
|
branch="${$(git symbolic-ref HEAD 2> /dev/null)#refs/heads/}"
|
2011-09-05 04:37:36 +00:00
|
|
|
|
|
|
|
# Format branch.
|
2012-12-22 14:09:54 +00:00
|
|
|
zstyle -s ':prezto:module:git:info:branch' format 'branch_format'
|
|
|
|
if [[ -n "$branch" && -n "$branch_format" ]]; then
|
2012-03-23 01:26:30 +00:00
|
|
|
zformat -f branch_formatted "$branch_format" "b:$branch"
|
2012-12-22 14:09:54 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Format position.
|
|
|
|
zstyle -s ':prezto:module:git:info:position' format 'position_format'
|
|
|
|
if [[ -z "$branch" && -n "$position_format" ]]; then
|
|
|
|
position="$(git describe --contains --all HEAD 2> /dev/null)"
|
|
|
|
if [[ -n "$position" ]]; then
|
|
|
|
zformat -f position_formatted "$position_format" "p:$position"
|
|
|
|
fi
|
|
|
|
fi
|
2011-09-05 04:37:36 +00:00
|
|
|
|
2012-12-22 14:09:54 +00:00
|
|
|
# Format remote.
|
|
|
|
zstyle -s ':prezto:module:git:info:remote' format 'remote_format'
|
|
|
|
if [[ -n "$branch" && -n "$remote_format" ]]; then
|
|
|
|
# Gets the remote name.
|
|
|
|
remote_cmd='git rev-parse --symbolic-full-name --verify HEAD@{upstream}'
|
2012-03-14 22:02:16 +00:00
|
|
|
remote="${$(${(z)remote_cmd} 2> /dev/null)##refs/remotes/}"
|
|
|
|
if [[ -n "$remote" ]]; then
|
|
|
|
zformat -f remote_formatted "$remote_format" "R:$remote"
|
2012-12-22 14:09:54 +00:00
|
|
|
fi
|
|
|
|
fi
|
2012-03-14 22:02:16 +00:00
|
|
|
|
2012-12-22 14:09:54 +00:00
|
|
|
zstyle -s ':prezto:module:git:info:ahead' format 'ahead_format'
|
|
|
|
zstyle -s ':prezto:module:git:info:behind' format 'behind_format'
|
|
|
|
if [[ -n "$branch" && ( -n "$ahead_format" || -n "$behind_format" ) ]]; then
|
|
|
|
# Gets the commit difference counts between local and remote.
|
|
|
|
ahead_and_behind_cmd='git rev-list --count --left-right HEAD...@{upstream}'
|
2012-03-14 22:02:16 +00:00
|
|
|
|
2012-12-22 14:09:54 +00:00
|
|
|
# Get ahead and behind counts.
|
|
|
|
ahead_and_behind="$(${(z)ahead_and_behind_cmd} 2> /dev/null)"
|
|
|
|
|
|
|
|
# Format ahead.
|
|
|
|
if [[ -n "$ahead_format" ]]; then
|
2012-03-14 22:02:16 +00:00
|
|
|
ahead="$ahead_and_behind[(w)1]"
|
2012-12-22 14:09:54 +00:00
|
|
|
if (( ahead > 0 )); then
|
2012-03-14 22:02:16 +00:00
|
|
|
zformat -f ahead_formatted "$ahead_format" "A:$ahead"
|
|
|
|
fi
|
2012-12-22 14:09:54 +00:00
|
|
|
fi
|
2011-09-05 04:37:36 +00:00
|
|
|
|
2012-12-22 14:09:54 +00:00
|
|
|
# Format behind.
|
|
|
|
if [[ -n "$behind_format" ]]; then
|
2012-03-14 22:02:16 +00:00
|
|
|
behind="$ahead_and_behind[(w)2]"
|
2012-12-22 14:09:54 +00:00
|
|
|
if (( behind > 0 )); then
|
2012-03-14 22:02:16 +00:00
|
|
|
zformat -f behind_formatted "$behind_format" "B:$behind"
|
|
|
|
fi
|
|
|
|
fi
|
2011-09-05 04:37:36 +00:00
|
|
|
fi
|
|
|
|
|
2012-12-22 22:48:19 +00:00
|
|
|
# Get status type.
|
|
|
|
if ! zstyle -t ':prezto:module:git:info' verbose; then
|
|
|
|
# Format indexed.
|
|
|
|
zstyle -s ':prezto:module:git:info:indexed' format 'indexed_format'
|
|
|
|
if [[ -n "$indexed_format" ]]; then
|
|
|
|
((
|
|
|
|
indexed+=$(
|
|
|
|
git diff-index \
|
|
|
|
--no-ext-diff \
|
|
|
|
--name-only \
|
|
|
|
--cached \
|
|
|
|
--ignore-submodules=${ignore_submodules:-none} \
|
|
|
|
HEAD \
|
|
|
|
2> /dev/null \
|
|
|
|
| wc -l
|
|
|
|
)
|
|
|
|
))
|
|
|
|
if (( indexed > 0 )); then
|
|
|
|
zformat -f indexed_formatted "$indexed_format" "i:$indexed"
|
|
|
|
fi
|
|
|
|
fi
|
2011-09-05 04:37:36 +00:00
|
|
|
|
2012-12-22 22:48:19 +00:00
|
|
|
# Format unindexed.
|
|
|
|
zstyle -s ':prezto:module:git:info:unindexed' format 'unindexed_format'
|
|
|
|
if [[ -n "$unindexed_format" ]]; then
|
|
|
|
((
|
|
|
|
unindexed+=$(
|
|
|
|
git diff-files \
|
|
|
|
--no-ext-diff \
|
|
|
|
--name-only \
|
|
|
|
--ignore-submodules=${ignore_submodules:-none} \
|
|
|
|
2> /dev/null \
|
|
|
|
| wc -l
|
|
|
|
)
|
|
|
|
))
|
|
|
|
if (( unindexed > 0 )); then
|
|
|
|
zformat -f unindexed_formatted "$unindexed_format" "I:$unindexed"
|
|
|
|
fi
|
|
|
|
fi
|
2011-09-05 04:37:36 +00:00
|
|
|
|
2012-12-22 22:48:19 +00:00
|
|
|
# Format untracked.
|
|
|
|
zstyle -s ':prezto:module:git:info:untracked' format 'untracked_format'
|
|
|
|
if [[ -n "$untracked_format" ]]; then
|
|
|
|
((
|
|
|
|
untracked+=$(
|
|
|
|
git ls-files \
|
|
|
|
--other \
|
|
|
|
--exclude-standard \
|
|
|
|
2> /dev/null \
|
|
|
|
| wc -l
|
|
|
|
)
|
|
|
|
))
|
|
|
|
if (( untracked > 0 )); then
|
|
|
|
zformat -f untracked_formatted "$untracked_format" "u:$untracked"
|
|
|
|
fi
|
|
|
|
fi
|
2011-09-05 04:37:36 +00:00
|
|
|
|
2012-12-22 22:48:19 +00:00
|
|
|
(( dirty = indexed + unindexed + untracked ))
|
|
|
|
else
|
|
|
|
# Use porcelain status for easy parsing.
|
|
|
|
status_cmd="git status --porcelain --ignore-submodules=${ignore_submodules:-none}"
|
|
|
|
|
|
|
|
# Get current status.
|
|
|
|
while IFS=$'\n' read line; do
|
|
|
|
# Count added, deleted, modified, renamed, unmerged, untracked, dirty.
|
|
|
|
# T (type change) is undocumented, see http://git.io/FnpMGw.
|
|
|
|
# For a table of scenarii, see http://i.imgur.com/2YLu1.png.
|
|
|
|
[[ "$line" == ([ACDMT][\ MT]|[ACMT]D)\ * ]] && (( added++ ))
|
|
|
|
[[ "$line" == [\ ACMRT]D\ * ]] && (( deleted++ ))
|
|
|
|
[[ "$line" == ?[MT]\ * ]] && (( modified++ ))
|
|
|
|
[[ "$line" == R?\ * ]] && (( renamed++ ))
|
|
|
|
[[ "$line" == (AA|DD|U?|?U)\ * ]] && (( unmerged++ ))
|
|
|
|
[[ "$line" == \?\?\ * ]] && (( untracked++ ))
|
|
|
|
(( dirty++ ))
|
|
|
|
done < <(${(z)status_cmd} 2> /dev/null)
|
|
|
|
|
|
|
|
# Format added.
|
|
|
|
if (( added > 0 )); then
|
|
|
|
zstyle -s ':prezto:module:git:info:added' format 'added_format'
|
|
|
|
zformat -f added_formatted "$added_format" "a:$added_format"
|
|
|
|
fi
|
2011-09-05 04:37:36 +00:00
|
|
|
|
2012-12-22 22:48:19 +00:00
|
|
|
# Format deleted.
|
|
|
|
if (( deleted > 0 )); then
|
|
|
|
zstyle -s ':prezto:module:git:info:deleted' format 'deleted_format'
|
|
|
|
zformat -f deleted_formatted "$deleted_format" "d:$deleted_format"
|
|
|
|
fi
|
2011-09-05 04:37:36 +00:00
|
|
|
|
2012-12-22 22:48:19 +00:00
|
|
|
# Format modified.
|
|
|
|
if (( modified > 0 )); then
|
|
|
|
zstyle -s ':prezto:module:git:info:modified' format 'modified_format'
|
|
|
|
zformat -f modified_formatted "$modified_format" "m:$modified"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Format renamed.
|
|
|
|
if (( renamed > 0 )); then
|
|
|
|
zstyle -s ':prezto:module:git:info:renamed' format 'renamed_format'
|
|
|
|
zformat -f renamed_formatted "$renamed_format" "r:$renamed"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Format unmerged.
|
|
|
|
if (( unmerged > 0 )); then
|
|
|
|
zstyle -s ':prezto:module:git:info:unmerged' format 'unmerged_format'
|
|
|
|
zformat -f unmerged_formatted "$unmerged_format" "U:$unmerged"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Format untracked.
|
|
|
|
if (( untracked > 0 )); then
|
|
|
|
zstyle -s ':prezto:module:git:info:untracked' format 'untracked_format'
|
|
|
|
zformat -f untracked_formatted "$untracked_format" "u:$untracked"
|
|
|
|
fi
|
2011-09-05 04:37:36 +00:00
|
|
|
fi
|
|
|
|
|
2012-04-12 01:21:11 +00:00
|
|
|
# Format dirty and clean.
|
2012-12-22 14:09:54 +00:00
|
|
|
if (( dirty > 0 )); then
|
2012-10-02 02:12:14 +00:00
|
|
|
zstyle -s ':prezto:module:git:info:dirty' format 'dirty_format'
|
2012-04-12 01:21:11 +00:00
|
|
|
zformat -f dirty_formatted "$dirty_format" "D:$dirty"
|
|
|
|
else
|
2012-10-02 02:12:14 +00:00
|
|
|
zstyle -s ':prezto:module:git:info:clean' format 'clean_formatted'
|
2012-04-12 01:21:11 +00:00
|
|
|
fi
|
2012-03-14 23:13:38 +00:00
|
|
|
|
2012-04-04 22:55:15 +00:00
|
|
|
# Format info.
|
2012-10-02 02:12:14 +00:00
|
|
|
zstyle -a ':prezto:module:git:info:keys' format 'info_formats'
|
2012-04-04 22:55:15 +00:00
|
|
|
for info_format in ${(k)info_formats}; do
|
|
|
|
zformat -f REPLY "$info_formats[$info_format]" \
|
2012-12-22 14:09:54 +00:00
|
|
|
"a:$added_formatted" \
|
2011-09-05 04:37:36 +00:00
|
|
|
"A:$ahead_formatted" \
|
|
|
|
"B:$behind_formatted" \
|
|
|
|
"b:$branch_formatted" \
|
2012-04-12 01:21:11 +00:00
|
|
|
"C:$clean_formatted" \
|
2011-09-05 04:37:36 +00:00
|
|
|
"c:$commit_formatted" \
|
|
|
|
"d:$deleted_formatted" \
|
2012-12-22 14:09:54 +00:00
|
|
|
"D:$dirty_formatted" \
|
2012-12-22 22:48:19 +00:00
|
|
|
"i:$indexed_formatted" \
|
|
|
|
"I:$unindexed_formatted" \
|
2011-09-05 04:37:36 +00:00
|
|
|
"m:$modified_formatted" \
|
2012-03-14 22:38:32 +00:00
|
|
|
"p:$position_formatted" \
|
2012-12-22 14:09:54 +00:00
|
|
|
"R:$remote_formatted" \
|
2011-09-05 04:37:36 +00:00
|
|
|
"r:$renamed_formatted" \
|
2012-03-14 22:38:32 +00:00
|
|
|
"s:$action_formatted" \
|
2012-12-22 14:09:54 +00:00
|
|
|
"S:$stashed_formatted" \
|
|
|
|
"U:$unmerged_formatted" \
|
2011-09-05 04:37:36 +00:00
|
|
|
"u:$untracked_formatted"
|
2012-04-04 22:55:15 +00:00
|
|
|
git_info[$info_format]="$REPLY"
|
2011-09-05 04:37:36 +00:00
|
|
|
done
|
|
|
|
|
2012-04-04 22:55:15 +00:00
|
|
|
unset REPLY
|
|
|
|
|
2011-09-05 04:37:36 +00:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2011-10-12 03:13:58 +00:00
|
|
|
git-info "$@"
|
|
|
|
|