summaryrefslogtreecommitdiff
path: root/Functions/VCS_Info/Backends
diff options
context:
space:
mode:
authorAxel Beckert <abe@deuxchevaux.org>2014-10-08 01:29:12 +0200
committerAxel Beckert <abe@deuxchevaux.org>2014-10-08 01:29:12 +0200
commit1c3f90e3af0c3d6c8e946653169287baf5814ad4 (patch)
tree9b15e9ad8157bd8f9f697f6dc4e59146b6833c59 /Functions/VCS_Info/Backends
parent1ffb184b46edd34d389af4e016abcaafec454d44 (diff)
parent9982ab6fb5266298c056326ed265fc8560202603 (diff)
downloadzsh-1c3f90e3af0c3d6c8e946653169287baf5814ad4.tar.gz
zsh-1c3f90e3af0c3d6c8e946653169287baf5814ad4.zip
Merge commit '9982ab6fb5266298c056326ed265fc8560202603' into debian
This is exactly one commit after the zsh-5.0.7 and adds one missing (and not unimportant) changelog entry for the 5.0.7 release.
Diffstat (limited to 'Functions/VCS_Info/Backends')
-rw-r--r--Functions/VCS_Info/Backends/VCS_INFO_get_data_git131
1 files changed, 84 insertions, 47 deletions
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index 76ab92f33..ee50be6ca 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -3,9 +3,9 @@
## Distributed under the same BSD-ish license as zsh itself.
setopt localoptions extendedglob NO_shwordsplit
-local gitdir gitbase gitbranch gitaction gitunstaged gitstaged gitsha1
-local stgitpatch stgitunapplied
+local gitdir gitbase gitbranch gitaction gitunstaged gitstaged gitsha1 gitmisc
local -i querystaged queryunstaged
+local -a git_patches_applied git_patches_unapplied
local -A hook_com
VCS_INFO_git_getaction () {
@@ -62,6 +62,11 @@ VCS_INFO_git_getaction () {
return 0
fi
+ if [[ -d "${gitdir}/sequencer" ]] ; then
+ gitaction="cherry-or-revert"
+ return 0
+ fi
+
return 1
}
@@ -108,8 +113,48 @@ VCS_INFO_git_getbranch () {
return 0
}
+VCS_INFO_git_handle_patches () {
+ local git_applied_s git_unapplied_s gitmsg git_all
+ git_patches_applied=(${(Oa)git_patches_applied})
+ git_patches_unapplied=(${(Oa)git_patches_unapplied})
+ (( git_all = ${#git_patches_applied} + ${#git_patches_unapplied} ))
+
+ if VCS_INFO_hook 'gen-applied-string' "${git_patches_applied[@]}"; then
+ if (( ${#git_patches_applied} )); then
+ git_applied_s=${git_patches_applied[1]}
+ else
+ git_applied_s=""
+ fi
+ else
+ git_applied_s=${hook_com[applied-string]}
+ fi
+ hook_com=()
+ if VCS_INFO_hook 'gen-unapplied-string' "${git_patches_unapplied[@]}"; then
+ git_patches_unapplied=${#git_patches_unapplied}
+ else
+ git_patches_unapplied=${hook_com[unapplied-string]}
+ fi
+
+ if (( ${#git_patches_applied} )); then
+ zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" patch-format gitmsg || gitmsg="%p (%n applied)"
+ else
+ zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" nopatch-format gitmsg || gitmsg="no patch applied"
+ fi
+ hook_com=( applied "${git_applied_s}" unapplied "${git_patches_unapplied}"
+ applied-n ${#git_patches_applied} unapplied-n ${#git_patches_unapplied} all-n ${git_all} )
+ if VCS_INFO_hook 'set-patch-format' "${gitmsg}"; then
+ zformat -f gitmisc "${gitmsg}" "p:${hook_com[applied]}" "u:${hook_com[unapplied]}" \
+ "n:${#git_patches_applied}" "c:${#git_patches_unapplied}" "a:${git_all}"
+ else
+ gitmisc=${hook_com[patch-replace]}
+ fi
+ hook_com=()
+}
+
gitdir=${vcs_comm[gitdir]}
VCS_INFO_git_getbranch ${gitdir}
+gitbase=$( ${vcs_comm[cmd]} rev-parse --show-toplevel )
+rrn=${gitbase:t}
if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" get-revision ; then
gitsha1=$(${vcs_comm[cmd]} rev-parse --quiet --verify HEAD)
else
@@ -131,17 +176,17 @@ if (( querystaged || queryunstaged )) && \
[[ "$(${vcs_comm[cmd]} rev-parse --is-inside-work-tree 2> /dev/null)" == 'true' ]] ; then
# Default: off - these are potentially expensive on big repositories
if (( queryunstaged )) ; then
- ${vcs_comm[cmd]} diff --no-ext-diff --ignore-submodules --quiet --exit-code ||
+ ${vcs_comm[cmd]} diff --no-ext-diff --ignore-submodules=dirty --quiet --exit-code ||
gitunstaged=1
fi
if (( querystaged )) ; then
if ${vcs_comm[cmd]} rev-parse --quiet --verify HEAD &> /dev/null ; then
- ${vcs_comm[cmd]} diff-index --cached --quiet --ignore-submodules HEAD 2> /dev/null
+ ${vcs_comm[cmd]} diff-index --cached --quiet --ignore-submodules=dirty HEAD 2> /dev/null
(( $? && $? != 128 )) && gitstaged=1
else
# empty repository (no commits yet)
# 4b825dc642cb6eb9a060e54bf8d69288fbee4904 is the git empty tree.
- ${vcs_comm[cmd]} diff-index --cached --quiet --ignore-submodules 4b825dc642cb6eb9a060e54bf8d69288fbee4904 2>/dev/null
+ ${vcs_comm[cmd]} diff-index --cached --quiet --ignore-submodules=dirty 4b825dc642cb6eb9a060e54bf8d69288fbee4904 2>/dev/null
(( $? && $? != 128 )) && gitstaged=1
fi
fi
@@ -149,55 +194,47 @@ fi
VCS_INFO_adjust
VCS_INFO_git_getaction ${gitdir}
-gitbase=$( ${vcs_comm[cmd]} rev-parse --show-toplevel )
-rrn=${gitbase:t}
+
+
+VCS_INFO_get_get_rebase()
+{
+ if [[ -f "$1" ]]; then
+ echo "$(< "$1")"
+ fi
+}
local patchdir=${gitdir}/patches/${gitbranch}
if [[ -d $patchdir ]] && [[ -f $patchdir/applied ]] \
&& [[ -f $patchdir/unapplied ]]
then
- local -a stgit_applied stgit_unapplied stgit_all
-
- stgit_applied=(${(f)"$(< "${patchdir}/applied")"})
- stgit_applied=( ${(Oa)stgit_applied} )
- stgit_unapplied=(${(f)"$(< "${patchdir}/unapplied")"})
- stgit_unapplied=( ${(oa)stgit_unapplied} )
- stgit_all=( ${(Oa)stgit_applied} ${stgit_unapplied} )
-
- if VCS_INFO_hook 'gen-applied-string' "${stgit_applied[@]}"; then
- if (( ${#stgit_applied} )); then
- stgitpatch=${stgit_applied[1]}
- else
- stgitpatch=""
- fi
- else
- stgitpatch=${hook_com[patch-string]}
- fi
- hook_com=()
- if VCS_INFO_hook 'gen-unapplied-string' "${stgit_unapplied[@]}"; then
- stgitunapplied=${#stgit_unapplied}
- else
- stgitunapplied=${hook_com[unapplied-string]}
- fi
+ git_patches_applied=(${(f)"$(< "${patchdir}/applied")"})
+ git_patches_unapplied=(${(f)"$(< "${patchdir}/unapplied")"})
+ VCS_INFO_git_handle_patches
+elif [[ -d "${gitdir}/rebase-merge" ]]; then
+ patchdir="${gitdir}/rebase-merge"
+ local p
+ for p in ${(f)"$(< "${patchdir}/done")"}; do
+ # remove action
+ git_patches_applied+=("${${(s: :)p}[2,-1]}")
+ done
+ git_patches_unapplied=(${(f)"$(grep -v '^$' "${patchdir}/git-rebase-todo" | grep -v '^#')"})
+ VCS_INFO_git_handle_patches
+elif [[ -d "${gitdir}/rebase-apply" ]]; then
+ # Fake patch names for all but current patch
+ patchdir="${gitdir}/rebase-apply"
+ local cur=$(< "${patchdir}/next")
+ local p
+ for p in $(seq $(($cur - 1))); do
+ git_patches_applied+=("$(printf "%04d" $p) ?")
+ done
+ git_patches_applied+=("$(< "${patchdir}/original-commit") ${${(f)$(< "${patchdir}/msg-clean")}[1]}")
+ git_patches_unapplied=($(seq $cur $(< "${patchdir}/last")))
- if (( ${#stgit_applied} )); then
- zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" patch-format stgitmsg || stgitmsg="%p (%n applied)"
- else
- zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" nopatch-format stgitmsg || stgitmsg="no patch applied"
- fi
- hook_com=( applied "${stgitpatch}" unapplied "${stgitunapplied}"
- applied-n ${#stgit_applied} unapplied-n ${#stgit_unapplied} all-n ${#stgit_all} )
- if VCS_INFO_hook 'set-patch-format' "${stgitmsg}"; then
- zformat -f stgitmsg "${stgitmsg}" "p:${hook_com[applied]}" "u:${hook_com[unapplied]}" \
- "n:${#stgit_applied}" "c:${#stgit_unapplied}" "a:${#stgit_all}"
- else
- stgitmsg=${hook_com[patch-replace]}
- fi
- hook_com=()
+ VCS_INFO_git_handle_patches
else
- stgitmsg=''
+ gitmisc=''
fi
-backend_misc[patches]="${stgitmsg}"
-VCS_INFO_formats "${gitaction}" "${gitbranch}" "${gitbase}" "${gitstaged}" "${gitunstaged}" "${gitsha1}" "${stgitmsg}"
+backend_misc[patches]="${gitmisc}"
+VCS_INFO_formats "${gitaction}" "${gitbranch}" "${gitbase}" "${gitstaged}" "${gitunstaged}" "${gitsha1}" "${gitmisc}"
return 0