|
|
@ -2654,7 +2654,8 @@ _p9k_vcs_info_init() {
|
|
|
|
|
|
|
|
|
|
|
|
function _p9k_vcs_status_save() {
|
|
|
|
function _p9k_vcs_status_save() {
|
|
|
|
local z=$'\0'
|
|
|
|
local z=$'\0'
|
|
|
|
_p9k__gitstatus_last[$VCS_STATUS_WORKDIR]=$VCS_STATUS_ACTION$z$VCS_STATUS_COMMIT\
|
|
|
|
_p9k__gitstatus_last[${${_p9k__git_dir:+GIT_DIR:$_p9k__git_dir}:-$VCS_STATUS_WORKDIR}]=\
|
|
|
|
|
|
|
|
$VCS_STATUS_ACTION$z$VCS_STATUS_COMMIT\
|
|
|
|
$z$VCS_STATUS_COMMITS_AHEAD$z$VCS_STATUS_COMMITS_BEHIND$z$VCS_STATUS_HAS_CONFLICTED\
|
|
|
|
$z$VCS_STATUS_COMMITS_AHEAD$z$VCS_STATUS_COMMITS_BEHIND$z$VCS_STATUS_HAS_CONFLICTED\
|
|
|
|
$z$VCS_STATUS_HAS_STAGED$z$VCS_STATUS_HAS_UNSTAGED$z$VCS_STATUS_HAS_UNTRACKED\
|
|
|
|
$z$VCS_STATUS_HAS_STAGED$z$VCS_STATUS_HAS_UNSTAGED$z$VCS_STATUS_HAS_UNTRACKED\
|
|
|
|
$z$VCS_STATUS_INDEX_SIZE$z$VCS_STATUS_LOCAL_BRANCH$z$VCS_STATUS_NUM_CONFLICTED\
|
|
|
|
$z$VCS_STATUS_INDEX_SIZE$z$VCS_STATUS_LOCAL_BRANCH$z$VCS_STATUS_NUM_CONFLICTED\
|
|
|
@ -2675,24 +2676,33 @@ function _p9k_vcs_status_restore() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function _p9k_vcs_status_for_dir() {
|
|
|
|
function _p9k_vcs_status_for_dir() {
|
|
|
|
local dir=$1
|
|
|
|
if [[ -n $GIT_DIR ]]; then
|
|
|
|
while true; do
|
|
|
|
_p9k_ret=$_p9k__gitstatus_last[GIT_DIR:$GIT_DIR]
|
|
|
|
_p9k_ret=$_p9k__gitstatus_last[$dir]
|
|
|
|
[[ -n $_p9k_ret ]]
|
|
|
|
[[ -n $_p9k_ret ]] && return 0
|
|
|
|
else
|
|
|
|
[[ $dir == / ]] && return 1
|
|
|
|
local dir=$_p9k_pwd_a
|
|
|
|
dir=${dir:h}
|
|
|
|
while true; do
|
|
|
|
done
|
|
|
|
_p9k_ret=$_p9k__gitstatus_last[$dir]
|
|
|
|
|
|
|
|
[[ -n $_p9k_ret ]] && return 0
|
|
|
|
|
|
|
|
[[ $dir == / ]] && return 1
|
|
|
|
|
|
|
|
dir=${dir:h}
|
|
|
|
|
|
|
|
done
|
|
|
|
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function _p9k_vcs_status_purge() {
|
|
|
|
function _p9k_vcs_status_purge() {
|
|
|
|
local dir=$1
|
|
|
|
if [[ -n $_p9k__git_dir ]]; then
|
|
|
|
while true; do
|
|
|
|
_p9k__gitstatus_last[GIT_DIR:$_p9k__git_dir]=""
|
|
|
|
# unset doesn't work if $dir contains weird shit
|
|
|
|
else
|
|
|
|
_p9k__gitstatus_last[$dir]=""
|
|
|
|
local dir=$1
|
|
|
|
_p9k_git_slow[$dir]=""
|
|
|
|
while true; do
|
|
|
|
[[ $dir == / ]] && break
|
|
|
|
# unset doesn't work if $dir contains weird shit
|
|
|
|
dir=${dir:h}
|
|
|
|
_p9k__gitstatus_last[$dir]=""
|
|
|
|
done
|
|
|
|
_p9k_git_slow[$dir]=""
|
|
|
|
|
|
|
|
[[ $dir == / ]] && break
|
|
|
|
|
|
|
|
dir=${dir:h}
|
|
|
|
|
|
|
|
done
|
|
|
|
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function _p9k_vcs_icon() {
|
|
|
|
function _p9k_vcs_icon() {
|
|
|
@ -2709,7 +2719,7 @@ function _p9k_vcs_render() {
|
|
|
|
local state
|
|
|
|
local state
|
|
|
|
|
|
|
|
|
|
|
|
if (( $+_p9k__gitstatus_next_dir )); then
|
|
|
|
if (( $+_p9k__gitstatus_next_dir )); then
|
|
|
|
if _p9k_vcs_status_for_dir ${${GIT_DIR:A}:-$_p9k_pwd_a}; then
|
|
|
|
if _p9k_vcs_status_for_dir; then
|
|
|
|
_p9k_vcs_status_restore $_p9k_ret
|
|
|
|
_p9k_vcs_status_restore $_p9k_ret
|
|
|
|
state=LOADING
|
|
|
|
state=LOADING
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -2900,9 +2910,9 @@ function _p9k_vcs_resume() {
|
|
|
|
if [[ $VCS_STATUS_RESULT == ok-async ]]; then
|
|
|
|
if [[ $VCS_STATUS_RESULT == ok-async ]]; then
|
|
|
|
local latency=$((EPOCHREALTIME - _p9k__gitstatus_start_time))
|
|
|
|
local latency=$((EPOCHREALTIME - _p9k__gitstatus_start_time))
|
|
|
|
if (( latency > _POWERLEVEL9K_VCS_MAX_SYNC_LATENCY_SECONDS )); then
|
|
|
|
if (( latency > _POWERLEVEL9K_VCS_MAX_SYNC_LATENCY_SECONDS )); then
|
|
|
|
_p9k_git_slow[$VCS_STATUS_WORKDIR]=1
|
|
|
|
_p9k_git_slow[${${_p9k__git_dir:+GIT_DIR:$_p9k__git_dir}:-$VCS_STATUS_WORKDIR}]=1
|
|
|
|
elif (( $1 && latency < 0.8 * _POWERLEVEL9K_VCS_MAX_SYNC_LATENCY_SECONDS )); then # 0.8 to avoid flip-flopping
|
|
|
|
elif (( $1 && latency < 0.8 * _POWERLEVEL9K_VCS_MAX_SYNC_LATENCY_SECONDS )); then # 0.8 to avoid flip-flopping
|
|
|
|
_p9k_git_slow[$VCS_STATUS_WORKDIR]=0
|
|
|
|
_p9k_git_slow[${${_p9k__git_dir:+GIT_DIR:$_p9k__git_dir}:-$VCS_STATUS_WORKDIR}]=0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
_p9k_vcs_status_save
|
|
|
|
_p9k_vcs_status_save
|
|
|
|
fi
|
|
|
|
fi
|
|
|
@ -2910,12 +2920,13 @@ function _p9k_vcs_resume() {
|
|
|
|
if [[ -z $_p9k__gitstatus_next_dir ]]; then
|
|
|
|
if [[ -z $_p9k__gitstatus_next_dir ]]; then
|
|
|
|
unset _p9k__gitstatus_next_dir
|
|
|
|
unset _p9k__gitstatus_next_dir
|
|
|
|
case $VCS_STATUS_RESULT in
|
|
|
|
case $VCS_STATUS_RESULT in
|
|
|
|
norepo-async) (( $1 )) && _p9k_vcs_status_purge ${${GIT_DIR:A}:-$_p9k_pwd_a};;
|
|
|
|
norepo-async) (( $1 )) && _p9k_vcs_status_purge $_p9k_pwd_a;;
|
|
|
|
ok-async) (( $1 )) || _p9k__gitstatus_next_dir=${${GIT_DIR:A}:-$_p9k_pwd_a};;
|
|
|
|
ok-async) (( $1 )) || _p9k__gitstatus_next_dir=$_p9k_pwd_a;;
|
|
|
|
esac
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [[ -n $_p9k__gitstatus_next_dir ]]; then
|
|
|
|
if [[ -n $_p9k__gitstatus_next_dir ]]; then
|
|
|
|
|
|
|
|
_p9k__git_dir=$GIT_DIR
|
|
|
|
if ! gitstatus_query -d $_p9k__gitstatus_next_dir -t 0 -c '_p9k_vcs_resume 1' POWERLEVEL9K; then
|
|
|
|
if ! gitstatus_query -d $_p9k__gitstatus_next_dir -t 0 -c '_p9k_vcs_resume 1' POWERLEVEL9K; then
|
|
|
|
unset _p9k__gitstatus_next_dir
|
|
|
|
unset _p9k__gitstatus_next_dir
|
|
|
|
unset VCS_STATUS_RESULT
|
|
|
|
unset VCS_STATUS_RESULT
|
|
|
@ -2935,12 +2946,12 @@ function _p9k_vcs_resume() {
|
|
|
|
function _p9k_vcs_gitstatus() {
|
|
|
|
function _p9k_vcs_gitstatus() {
|
|
|
|
if [[ $_p9k_refresh_reason == precmd ]]; then
|
|
|
|
if [[ $_p9k_refresh_reason == precmd ]]; then
|
|
|
|
if (( $+_p9k__gitstatus_next_dir )); then
|
|
|
|
if (( $+_p9k__gitstatus_next_dir )); then
|
|
|
|
_p9k__gitstatus_next_dir=${${GIT_DIR:A}:-$_p9k_pwd_a}
|
|
|
|
_p9k__gitstatus_next_dir=$_p9k_pwd_a
|
|
|
|
else
|
|
|
|
else
|
|
|
|
local dir=${${GIT_DIR:A}:-$_p9k_pwd_a}
|
|
|
|
|
|
|
|
local -F timeout=_POWERLEVEL9K_VCS_MAX_SYNC_LATENCY_SECONDS
|
|
|
|
local -F timeout=_POWERLEVEL9K_VCS_MAX_SYNC_LATENCY_SECONDS
|
|
|
|
if ! _p9k_vcs_status_for_dir $dir; then
|
|
|
|
if ! _p9k_vcs_status_for_dir; then
|
|
|
|
gitstatus_query -d $dir -t $timeout -p -c '_p9k_vcs_resume 0' POWERLEVEL9K || return 1
|
|
|
|
_p9k__git_dir=$GIT_DIR
|
|
|
|
|
|
|
|
gitstatus_query -d $_p9k_pwd_a -t $timeout -p -c '_p9k_vcs_resume 0' POWERLEVEL9K || return 1
|
|
|
|
_p9k_maybe_ignore_git_repo
|
|
|
|
_p9k_maybe_ignore_git_repo
|
|
|
|
case $VCS_STATUS_RESULT in
|
|
|
|
case $VCS_STATUS_RESULT in
|
|
|
|
tout) _p9k__gitstatus_next_dir=''; _p9k__gitstatus_start_time=$EPOCHREALTIME; return 0;;
|
|
|
|
tout) _p9k__gitstatus_next_dir=''; _p9k__gitstatus_start_time=$EPOCHREALTIME; return 0;;
|
|
|
@ -2948,24 +2959,29 @@ function _p9k_vcs_gitstatus() {
|
|
|
|
ok-sync) _p9k_vcs_status_save;;
|
|
|
|
ok-sync) _p9k_vcs_status_save;;
|
|
|
|
esac
|
|
|
|
esac
|
|
|
|
else
|
|
|
|
else
|
|
|
|
while true; do
|
|
|
|
if [[ -n $GIT_DIR ]]; then
|
|
|
|
case $_p9k_git_slow[$dir] in
|
|
|
|
[[ $_p9k_git_slow[GIT_DIR:$GIT_DIR] == 1 ]] && timeout=0
|
|
|
|
"") [[ $dir == / ]] && break; dir=${dir:h};;
|
|
|
|
else
|
|
|
|
0) break;;
|
|
|
|
local dir=$_p9k_pwd_a
|
|
|
|
1) timeout=0; break;;
|
|
|
|
while true; do
|
|
|
|
esac
|
|
|
|
case $_p9k_git_slow[$dir] in
|
|
|
|
done
|
|
|
|
"") [[ $dir == / ]] && break; dir=${dir:h};;
|
|
|
|
dir=${${GIT_DIR:A}:-$_p9k_pwd_a}
|
|
|
|
0) break;;
|
|
|
|
|
|
|
|
1) timeout=0; break;;
|
|
|
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
done
|
|
|
|
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
(( _p9k__prompt_idx == 1 )) && timeout=0
|
|
|
|
(( _p9k__prompt_idx == 1 )) && timeout=0
|
|
|
|
if ! gitstatus_query -d $dir -t $timeout -c '_p9k_vcs_resume 1' POWERLEVEL9K; then
|
|
|
|
_p9k__git_dir=$GIT_DIR
|
|
|
|
|
|
|
|
if ! gitstatus_query -d $_p9k_pwd_a -t $timeout -c '_p9k_vcs_resume 1' POWERLEVEL9K; then
|
|
|
|
unset VCS_STATUS_RESULT
|
|
|
|
unset VCS_STATUS_RESULT
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
_p9k_maybe_ignore_git_repo
|
|
|
|
_p9k_maybe_ignore_git_repo
|
|
|
|
case $VCS_STATUS_RESULT in
|
|
|
|
case $VCS_STATUS_RESULT in
|
|
|
|
tout) _p9k__gitstatus_next_dir=''; _p9k__gitstatus_start_time=$EPOCHREALTIME;;
|
|
|
|
tout) _p9k__gitstatus_next_dir=''; _p9k__gitstatus_start_time=$EPOCHREALTIME;;
|
|
|
|
norepo-sync) _p9k_vcs_status_purge $dir;;
|
|
|
|
norepo-sync) _p9k_vcs_status_purge $_p9k_pwd_a;;
|
|
|
|
ok-sync) _p9k_vcs_status_save;;
|
|
|
|
ok-sync) _p9k_vcs_status_save;;
|
|
|
|
esac
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
fi
|
|
|
@ -4501,6 +4517,7 @@ _p9k_init_vars() {
|
|
|
|
typeset -ga _p9k_right_join
|
|
|
|
typeset -ga _p9k_right_join
|
|
|
|
typeset -g _p9k__public_ip
|
|
|
|
typeset -g _p9k__public_ip
|
|
|
|
typeset -g _p9k_todo_file
|
|
|
|
typeset -g _p9k_todo_file
|
|
|
|
|
|
|
|
typeset -g _p9k__git_dir
|
|
|
|
# git workdir => 1 if gitstatus is slow on it, 0 if it's fast.
|
|
|
|
# git workdir => 1 if gitstatus is slow on it, 0 if it's fast.
|
|
|
|
typeset -gA _p9k_git_slow
|
|
|
|
typeset -gA _p9k_git_slow
|
|
|
|
# git workdir => the last state we've seen for it
|
|
|
|
# git workdir => the last state we've seen for it
|
|
|
|