diff options
author | Daniel Shahaf <d.s@daniel.shahaf.name> | 2014-03-28 11:00:35 +0000 |
---|---|---|
committer | Frank Terbeck <ft@bewatermyfriend.org> | 2014-04-05 10:56:52 +0200 |
commit | eb4c70d0b7856a8ddfeb4ea2d3d83991f5cb82d3 (patch) | |
tree | 67083cf89a40cb81bcd18a32f59bc6c425bb34e6 /Functions | |
parent | 4dfe62640a786f60e72af64021910c6ac11167cc (diff) | |
download | zsh-eb4c70d0b7856a8ddfeb4ea2d3d83991f5cb82d3.tar.gz zsh-eb4c70d0b7856a8ddfeb4ea2d3d83991f5cb82d3.tar.xz zsh-eb4c70d0b7856a8ddfeb4ea2d3d83991f5cb82d3.zip |
32528: vcs_info: Add check-for-staged-changes
Diffstat (limited to 'Functions')
-rw-r--r-- | Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git index e6791cb7a..6512851cc 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git @@ -5,6 +5,7 @@ setopt localoptions extendedglob NO_shwordsplit local gitdir gitbase gitbranch gitaction gitunstaged gitstaged gitsha1 local stgitpatch stgitunapplied +local -i querystaged queryunstaged local -A hook_com VCS_INFO_git_getaction () { @@ -120,14 +121,24 @@ if [[ -z ${gitdir} ]] || [[ -z ${gitbranch} ]] ; then return 1 fi -if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" "check-for-changes" && \ +if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" "check-for-changes" ; then + querystaged=1 + queryunstaged=1 +elif zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" "check-for-staged-changes" ; then + querystaged=1 +fi +if (( querystaged || queryunstaged )) && \ [[ "$(${vcs_comm[cmd]} rev-parse --is-inside-git-dir 2> /dev/null)" != 'true' ]] && \ ${vcs_comm[cmd]} rev-parse --quiet --verify HEAD &> /dev/null ; then # Default: off - these are potentially expensive on big repositories - ${vcs_comm[cmd]} diff --no-ext-diff --ignore-submodules --quiet --exit-code || - gitunstaged=1 - ${vcs_comm[cmd]} diff-index --cached --quiet --ignore-submodules HEAD 2> /dev/null - (( $? && $? != 128 )) && gitstaged=1 + if (( queryunstaged )) ; then + ${vcs_comm[cmd]} diff --no-ext-diff --ignore-submodules --quiet --exit-code || + gitunstaged=1 + fi + if (( querystaged )) ; then + ${vcs_comm[cmd]} diff-index --cached --quiet --ignore-submodules HEAD 2> /dev/null + (( $? && $? != 128 )) && gitstaged=1 + fi fi VCS_INFO_adjust |