diff options
Diffstat (limited to 'gitstatus/gitstatus.plugin.sh')
-rw-r--r-- | gitstatus/gitstatus.plugin.sh | 50 |
1 files changed, 12 insertions, 38 deletions
diff --git a/gitstatus/gitstatus.plugin.sh b/gitstatus/gitstatus.plugin.sh index 61b81e6a..95c5402e 100644 --- a/gitstatus/gitstatus.plugin.sh +++ b/gitstatus/gitstatus.plugin.sh @@ -264,50 +264,18 @@ function gitstatus_start() { return 1 fi + export _GITSTATUS_CLIENT_PID _GITSTATUS_REQ_FD _GITSTATUS_RESP_FD GITSTATUS_DAEMON_PID unset -f gitstatus_start_impl - - if [[ "${GITSTATUS_STOP_ON_EXEC:-1}" == 1 ]]; then - type -t _gitstatus_exec &>/dev/null || function _gitstatus_exec() { exec "$@"; } - type -t _gitstatus_builtin &>/dev/null || function _gitstatus_builtin() { builtin "$@"; } - - function _gitstatus_exec_wrapper() { - (( ! $# )) || gitstatus_stop - local ret=0 - _gitstatus_exec "$@" || ret=$? - [[ -n "${GITSTATUS_DAEMON_PID:-}" ]] || gitstatus_start || true - return $ret - } - - function _gitstatus_builtin_wrapper() { - while [[ "${1:-}" == builtin ]]; do shift; done - if [[ "${1:-}" == exec ]]; then - _gitstatus_exec_wrapper "${@:2}" - else - _gitstatus_builtin "$@" - fi - } - - alias exec=_gitstatus_exec_wrapper - alias builtin=_gitstatus_builtin_wrapper - - _GITSTATUS_EXEC_HOOK=1 - else - unset _GITSTATUS_EXEC_HOOK - fi } # Stops gitstatusd if it's running. function gitstatus_stop() { - [[ "${_GITSTATUS_CLIENT_PID:-$BASHPID}" == "$BASHPID" ]] || return 0 - [[ -z "${_GITSTATUS_REQ_FD:-}" ]] || exec {_GITSTATUS_REQ_FD}>&- || true - [[ -z "${_GITSTATUS_RESP_FD:-}" ]] || exec {_GITSTATUS_RESP_FD}>&- || true - [[ -z "${GITSTATUS_DAEMON_PID:-}" ]] || kill "$GITSTATUS_DAEMON_PID" &>/dev/null || true - if [[ -n "${_GITSTATUS_EXEC_HOOK:-}" ]]; then - unalias exec builtin &>/dev/null || true - function _gitstatus_exec_wrapper() { _gitstatus_exec "$@"; } - function _gitstatus_builtin_wrapper() { _gitstatus_builtin "$@"; } + if [[ "${_GITSTATUS_CLIENT_PID:-$BASHPID}" == "$BASHPID" ]]; then + [[ -z "${_GITSTATUS_REQ_FD:-}" ]] || exec {_GITSTATUS_REQ_FD}>&- || true + [[ -z "${_GITSTATUS_RESP_FD:-}" ]] || exec {_GITSTATUS_RESP_FD}>&- || true + [[ -z "${GITSTATUS_DAEMON_PID:-}" ]] || kill "$GITSTATUS_DAEMON_PID" &>/dev/null || true fi - unset _GITSTATUS_REQ_FD _GITSTATUS_RESP_FD GITSTATUS_DAEMON_PID _GITSTATUS_EXEC_HOOK + unset _GITSTATUS_REQ_FD _GITSTATUS_RESP_FD GITSTATUS_DAEMON_PID unset _GITSTATUS_DIRTY_MAX_INDEX_SIZE _GITSTATUS_CLIENT_PID } @@ -332,6 +300,8 @@ function gitstatus_stop() { # VCS_STATUS_WORKDIR Git repo working directory. Not empty. # VCS_STATUS_COMMIT Commit hash that HEAD is pointing to. Either 40 hex digits or # empty if there is no HEAD (empty repo). +# VCS_STATUS_COMMIT_ENCODING Encoding of the HEAD's commit message. Empty value means UTF-8. +# VCS_STATUS_COMMIT_SUMMARY The first paragraph of the HEAD's commit message as one line. # VCS_STATUS_LOCAL_BRANCH Local branch name or empty if not on a branch. # VCS_STATUS_REMOTE_NAME The remote name, e.g. "upstream" or "origin". # VCS_STATUS_REMOTE_BRANCH Upstream branch name. Can be empty. @@ -435,6 +405,8 @@ function gitstatus_query() { VCS_STATUS_PUSH_COMMITS_BEHIND="${resp[24]:-0}" VCS_STATUS_NUM_SKIP_WORKTREE="${resp[25]:-0}" VCS_STATUS_NUM_ASSUME_UNCHANGED="${resp[26]:-0}" + VCS_STATUS_COMMIT_ENCODING="${resp[27]-}" + VCS_STATUS_COMMIT_SUMMARY="${resp[28]-}" VCS_STATUS_HAS_STAGED=$((VCS_STATUS_NUM_STAGED > 0)) if (( _GITSTATUS_DIRTY_MAX_INDEX_SIZE >= 0 && VCS_STATUS_INDEX_SIZE > _GITSTATUS_DIRTY_MAX_INDEX_SIZE_ )); then @@ -477,6 +449,8 @@ function gitstatus_query() { unset VCS_STATUS_PUSH_COMMITS_BEHIND unset VCS_STATUS_NUM_SKIP_WORKTREE unset VCS_STATUS_NUM_ASSUME_UNCHANGED + unset VCS_STATUS_COMMIT_ENCODING + unset VCS_STATUS_COMMIT_SUMMARY fi } |