|
|
@ -151,6 +151,9 @@ function git-info { |
|
|
|
local dirty_format |
|
|
|
local dirty_format |
|
|
|
local dirty_formatted |
|
|
|
local dirty_formatted |
|
|
|
local ignore_submodules |
|
|
|
local ignore_submodules |
|
|
|
|
|
|
|
local indexed=0 |
|
|
|
|
|
|
|
local indexed_format |
|
|
|
|
|
|
|
local indexed_formatted |
|
|
|
local -A info_formats |
|
|
|
local -A info_formats |
|
|
|
local info_format |
|
|
|
local info_format |
|
|
|
local line_number=0 |
|
|
|
local line_number=0 |
|
|
@ -171,6 +174,10 @@ function git-info { |
|
|
|
local stashed_format |
|
|
|
local stashed_format |
|
|
|
local stashed_formatted |
|
|
|
local stashed_formatted |
|
|
|
local status_cmd |
|
|
|
local status_cmd |
|
|
|
|
|
|
|
local status_mode |
|
|
|
|
|
|
|
local unindexed=0 |
|
|
|
|
|
|
|
local unindexed_format |
|
|
|
|
|
|
|
local unindexed_formatted |
|
|
|
local unmerged=0 |
|
|
|
local unmerged=0 |
|
|
|
local unmerged_format |
|
|
|
local unmerged_format |
|
|
|
local unmerged_formatted |
|
|
|
local unmerged_formatted |
|
|
@ -291,57 +298,117 @@ function git-info { |
|
|
|
fi |
|
|
|
fi |
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
# Use porcelain status for easy parsing. |
|
|
|
# Get status type. |
|
|
|
status_cmd="git status --porcelain --ignore-submodules=${ignore_submodules:-none}" |
|
|
|
if ! zstyle -t ':prezto:module:git:info' verbose; then |
|
|
|
|
|
|
|
# Format indexed. |
|
|
|
# Get current status. |
|
|
|
zstyle -s ':prezto:module:git:info:indexed' format 'indexed_format' |
|
|
|
while IFS=$'\n' read line; do |
|
|
|
if [[ -n "$indexed_format" ]]; then |
|
|
|
# Count added, deleted, modified, renamed, unmerged, untracked, dirty. |
|
|
|
(( |
|
|
|
# T (type change) is undocumented, see http://git.io/FnpMGw. |
|
|
|
indexed+=$( |
|
|
|
# For a table of scenarii, see http://i.imgur.com/2YLu1.png. |
|
|
|
git diff-index \ |
|
|
|
[[ "$line" == ([ACDMT][\ MT]|[ACMT]D)\ * ]] && (( added++ )) |
|
|
|
--no-ext-diff \ |
|
|
|
[[ "$line" == [\ ACMRT]D\ * ]] && (( deleted++ )) |
|
|
|
--name-only \ |
|
|
|
[[ "$line" == ?[MT]\ * ]] && (( modified++ )) |
|
|
|
--cached \ |
|
|
|
[[ "$line" == R?\ * ]] && (( renamed++ )) |
|
|
|
--ignore-submodules=${ignore_submodules:-none} \ |
|
|
|
[[ "$line" == (AA|DD|U?|?U)\ * ]] && (( unmerged++ )) |
|
|
|
HEAD \ |
|
|
|
[[ "$line" == \?\?\ * ]] && (( untracked++ )) |
|
|
|
2> /dev/null \ |
|
|
|
(( dirty++ )) |
|
|
|
| wc -l |
|
|
|
done < <(${(z)status_cmd} 2> /dev/null) |
|
|
|
) |
|
|
|
|
|
|
|
)) |
|
|
|
# Format added. |
|
|
|
if (( indexed > 0 )); then |
|
|
|
if (( added > 0 )); then |
|
|
|
zformat -f indexed_formatted "$indexed_format" "i:$indexed" |
|
|
|
zstyle -s ':prezto:module:git:info:added' format 'added_format' |
|
|
|
fi |
|
|
|
zformat -f added_formatted "$added_format" "a:$added_format" |
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Format deleted. |
|
|
|
# Format unindexed. |
|
|
|
if (( deleted > 0 )); then |
|
|
|
zstyle -s ':prezto:module:git:info:unindexed' format 'unindexed_format' |
|
|
|
zstyle -s ':prezto:module:git:info:deleted' format 'deleted_format' |
|
|
|
if [[ -n "$unindexed_format" ]]; then |
|
|
|
zformat -f deleted_formatted "$deleted_format" "d:$deleted_format" |
|
|
|
(( |
|
|
|
fi |
|
|
|
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 |
|
|
|
|
|
|
|
|
|
|
|
# Format modified. |
|
|
|
# Format untracked. |
|
|
|
if (( modified > 0 )); then |
|
|
|
zstyle -s ':prezto:module:git:info:untracked' format 'untracked_format' |
|
|
|
zstyle -s ':prezto:module:git:info:modified' format 'modified_format' |
|
|
|
if [[ -n "$untracked_format" ]]; then |
|
|
|
zformat -f modified_formatted "$modified_format" "m:$modified" |
|
|
|
(( |
|
|
|
fi |
|
|
|
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 |
|
|
|
|
|
|
|
|
|
|
|
# Format renamed. |
|
|
|
(( dirty = indexed + unindexed + untracked )) |
|
|
|
if (( renamed > 0 )); then |
|
|
|
else |
|
|
|
zstyle -s ':prezto:module:git:info:renamed' format 'renamed_format' |
|
|
|
# Use porcelain status for easy parsing. |
|
|
|
zformat -f renamed_formatted "$renamed_format" "r:$renamed" |
|
|
|
status_cmd="git status --porcelain --ignore-submodules=${ignore_submodules:-none}" |
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
# 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 |
|
|
|
|
|
|
|
|
|
|
|
# Format unmerged. |
|
|
|
# Format deleted. |
|
|
|
if (( unmerged > 0 )); then |
|
|
|
if (( deleted > 0 )); then |
|
|
|
zstyle -s ':prezto:module:git:info:unmerged' format 'unmerged_format' |
|
|
|
zstyle -s ':prezto:module:git:info:deleted' format 'deleted_format' |
|
|
|
zformat -f unmerged_formatted "$unmerged_format" "U:$unmerged" |
|
|
|
zformat -f deleted_formatted "$deleted_format" "d:$deleted_format" |
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
# Format untracked. |
|
|
|
# Format modified. |
|
|
|
if (( untracked > 0 )); then |
|
|
|
if (( modified > 0 )); then |
|
|
|
zstyle -s ':prezto:module:git:info:untracked' format 'untracked_format' |
|
|
|
zstyle -s ':prezto:module:git:info:modified' format 'modified_format' |
|
|
|
zformat -f untracked_formatted "$untracked_format" "u:$untracked" |
|
|
|
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 |
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
# Format dirty and clean. |
|
|
|
# Format dirty and clean. |
|
|
@ -364,6 +431,8 @@ function git-info { |
|
|
|
"c:$commit_formatted" \ |
|
|
|
"c:$commit_formatted" \ |
|
|
|
"d:$deleted_formatted" \ |
|
|
|
"d:$deleted_formatted" \ |
|
|
|
"D:$dirty_formatted" \ |
|
|
|
"D:$dirty_formatted" \ |
|
|
|
|
|
|
|
"i:$indexed_formatted" \ |
|
|
|
|
|
|
|
"I:$unindexed_formatted" \ |
|
|
|
"m:$modified_formatted" \ |
|
|
|
"m:$modified_formatted" \ |
|
|
|
"p:$position_formatted" \ |
|
|
|
"p:$position_formatted" \ |
|
|
|
"R:$remote_formatted" \ |
|
|
|
"R:$remote_formatted" \ |
|
|
|