From 5e40996891e0eaa9d35177e5e848a4b46d47b97e Mon Sep 17 00:00:00 2001 From: Marc Finet Date: Fri, 12 Sep 2014 23:30:37 +0200 Subject: 33147: vcs_info git: detect revert or cherry-pick with multiple commits When revert or cherry-pick involve many commits the .git/sequencer directory holds context for the action and no CHERRY_PICK_HEAD exist. --- Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Functions/VCS_Info/Backends') diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git index 76ab92f33..263a3258e 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git @@ -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 } -- cgit v1.2.3 From d5f574e20a7cc4c202433fe28f30c37b13299d61 Mon Sep 17 00:00:00 2001 From: Marc Finet Date: Fri, 12 Sep 2014 23:30:41 +0200 Subject: 33145: vcs_info git: fix applied-string name Documentation and hg backend use applied-string. patch-string does not appear anywhere. --- ChangeLog | 3 +++ Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'Functions/VCS_Info/Backends') diff --git a/ChangeLog b/ChangeLog index ec6557e1d..7ae89daf5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,9 @@ * 33148: Functions/VCS_Info/VCS_INFO_quilt: vcs_info quilt: refactor standalone detection + * 33145: Functions/VCS_Info/Backends/VCS_INFO_get_data_git: + vcs_info git: fix applied-string name + 2014-09-12 Barton E. Schaefer * 33143: Src/init.c: POSIX_ARGZERO more closely matches bash et al. diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git index 263a3258e..8f9aa2a19 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git @@ -176,7 +176,7 @@ then stgitpatch="" fi else - stgitpatch=${hook_com[patch-string]} + stgitpatch=${hook_com[applied-string]} fi hook_com=() if VCS_INFO_hook 'gen-unapplied-string' "${stgit_unapplied[@]}"; then -- cgit v1.2.3 From 2c2d4f9627258640df44a4da4e5627e4d8c5044d Mon Sep 17 00:00:00 2001 From: Marc Finet Date: Tue, 16 Sep 2014 22:57:26 +0200 Subject: 33188: vcs_info git: set rrn before using it This would fix handling get-revision, check-for-changes or check-for-staged-changes when set per repository. --- ChangeLog | 5 +++++ Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'Functions/VCS_Info/Backends') diff --git a/ChangeLog b/ChangeLog index a06461fa3..037604772 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-09-16 Marc Finet + + * 33188: Functions/VCS_Info/Backends/VCS_INFO_get_data_git: + vcs_info git: set rrn before using it + 2014-09-16 Mikael Magnusson * 33136: Doc/Zsh/expn.yo, Src/glob.c: P glob qualifier appends diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git index 8f9aa2a19..24efab22e 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git @@ -115,6 +115,8 @@ VCS_INFO_git_getbranch () { 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 @@ -154,8 +156,6 @@ fi VCS_INFO_adjust VCS_INFO_git_getaction ${gitdir} -gitbase=$( ${vcs_comm[cmd]} rev-parse --show-toplevel ) -rrn=${gitbase:t} local patchdir=${gitdir}/patches/${gitbranch} if [[ -d $patchdir ]] && [[ -f $patchdir/applied ]] \ -- cgit v1.2.3 From 9c29a4f1f6297d97d4644b074f7246b980751e2b Mon Sep 17 00:00:00 2001 From: Marc Finet Date: Tue, 16 Sep 2014 22:07:59 +0200 Subject: 33184: vcs_info git: consider patches for rebase Since a rebase contains a list of patches to re-apply, re-use the facility for stgit to have the same mechanism. The patch list given to the gen-{un,}applied-string hooks is an array with the sha1 and the subject of the commit. On rebase merge, the applied patches prior to current contains only a number and "?". --- ChangeLog | 4 + Doc/Zsh/contrib.yo | 14 +-- Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 116 ++++++++++++++-------- 3 files changed, 85 insertions(+), 49 deletions(-) (limited to 'Functions/VCS_Info/Backends') diff --git a/ChangeLog b/ChangeLog index 037604772..7d1ea2b23 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,10 @@ * 33188: Functions/VCS_Info/Backends/VCS_INFO_get_data_git: vcs_info git: set rrn before using it + * 33184: Doc/Zsh/contrib.yo, + Functions/VCS_Info/Backends/VCS_INFO_get_data_git: vcs_info git: + consider patches for rebase + 2014-09-16 Mikael Magnusson * 33136: Doc/Zsh/expn.yo, Src/glob.c: P glob qualifier appends diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index 1c1a66a3b..361e86681 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -1296,10 +1296,10 @@ tt(formats) and tt(actionformats) and will be availabe in the global tt(backend_misc) array as tt(${backend_misc[bookmarks]}). ) item(tt(gen-applied-string))( -Called in the tt(git) (with tt(stgit)), and tt(hg) (with tt(mq)) backends -and in tt(quilt) support when the tt(applied-string) is generated; the -tt(use-quilt) zstyle must be true for tt(quilt) (the tt(mq) and tt(stgit) -backends are active by default). +Called in the tt(git) (with tt(stgit) or during rebase), and tt(hg) +(with tt(mq)) backends and in tt(quilt) support when the tt(applied-string) +is generated; the tt(use-quilt) zstyle must be true for tt(quilt) (the tt(mq) +and tt(stgit) backends are active by default). This hook gets the names of all applied patches which tt(vcs_info) collected so far in the opposite order, which means that the first argument is the @@ -1312,9 +1312,9 @@ tt(backend_misc) array as tt($backend_misc[patches]}); and it will be available as tt(%p) in the tt(patch-format) and tt(nopatch-format) styles. ) item(tt(gen-unapplied-string))( -Called in the tt(git) (with tt(stgit)), and tt(hg) (with tt(mq)) backend -and in tt(quilt) support when the tt(unapplied-string) is generated; the -tt(get-unapplied) style must be true. +Called in the tt(git) (with tt(stgit) or during rebase), and tt(hg) (with +tt(mq)) backend and in tt(quilt) support when the tt(unapplied-string) is +generated; the tt(get-unapplied) style must be true. This hook gets the names of all unapplied patches which tt(vcs_info) collected so far in the opposite order, which mean that the first argument is diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git index 24efab22e..c243bf7ba 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 () { @@ -113,6 +113,44 @@ 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 ) @@ -157,52 +195,46 @@ fi VCS_INFO_adjust VCS_INFO_git_getaction ${gitdir} + +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[applied-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 -- cgit v1.2.3 From 64e2b4426e72e0359cd4c621ab2e2f521050e620 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Mon, 22 Sep 2014 16:37:23 +0200 Subject: 33217: vcs_info: use `--ignore-submodules=dirty` with diff/diff-index This will detect changes to submodules from the superproject's perspective, e.g. after `git rm submodule`. >From GIT-DIFF-INDEX(1)/GIT-DIFF(1): Using "dirty" ignores all changes to the work tree of submodules, only changes to the commits stored in the superproject are shown (this was the behavior until 1.7.0). --- ChangeLog | 5 +++++ Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'Functions/VCS_Info/Backends') diff --git a/ChangeLog b/ChangeLog index f32094f21..faa3f8731 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-09-22 Daniel Hahler + + * 33217: Functions/VCS_Info/Backends/VCS_INFO_get_data_git: + vcs_info: use `--ignore-submodules=dirty` with diff/diff-index + 2014-09-22 Peter Stephenson * 33208: Tanu Kaskinen: diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git index c243bf7ba..ee50be6ca 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git @@ -176,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 -- cgit v1.2.3