From 45bdc87a1f4058f9a8cd5eaceda704284d4a89a1 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Wed, 23 Sep 2015 20:55:40 +0200 Subject: 36601: vcs_info: handle missing .git/rebase-apply/{next,msg-clean} When pressing Ctrl-C after `git am`, only `last` exists in `.git/rebase-apply/`, which is empty. This patch fixes it to fall back to "no patch applied" then. --- Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 25 +++++++++++++---------- 1 file changed, 14 insertions(+), 11 deletions(-) (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 638ea4572..8ecc7c7f7 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git @@ -217,18 +217,21 @@ elif [[ -d "${gitdir}/rebase-merge" ]]; then elif [[ -d "${gitdir}/rebase-apply" ]]; then # Fake patch names for all but current patch patchdir="${gitdir}/rebase-apply" - local cur=$(< "${patchdir}/next") - local p subject - for p in $(seq $(($cur - 1))); do - git_patches_applied+=("$(printf "%04d" $p) ?") - done - subject="${$(< "${patchdir}/msg-clean")[(f)1]}" - if [[ -f "${patchdir}/original-commit" ]]; then - git_patches_applied+=("$(< ${patchdir}/original-commit) $subject") - else - git_patches_applied+=("? $subject") + local next="${patchdir}/next" + if [[ -f $next ]]; then + local cur=$(< $next) + local p subject + for p in $(seq $(($cur - 1))); do + git_patches_applied+=("$(printf "%04d" $p) ?") + done + subject="${$(< "${patchdir}/msg-clean")[(f)1]}" + if [[ -f "${patchdir}/original-commit" ]]; then + git_patches_applied+=("$(< ${patchdir}/original-commit) $subject") + else + git_patches_applied+=("? $subject") + fi + git_patches_unapplied=($(seq $cur $(< "${patchdir}/last"))) fi - git_patches_unapplied=($(seq $cur $(< "${patchdir}/last"))) VCS_INFO_git_handle_patches elif [[ -f "${gitdir}/MERGE_HEAD" ]]; then -- cgit v1.2.3 From 7ac34a3055d87b88d8b1b28ddfe68982f6550a08 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 30 Sep 2015 14:21:59 +0000 Subject: 36725: vcs_info git: Compute %b correctly when merging to detached heads. The %b expando should be the hash prior to the merge. The hash of the merge result is available as the %i expando and via the gen-applied-string hook. --- ChangeLog | 6 ++++++ Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'Functions/VCS_Info/Backends') diff --git a/ChangeLog b/ChangeLog index 498ad7c87..9a755434a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2015-09-30 Daniel Shahaf + + * 36725: Functions/VCS_Info/Backends/VCS_INFO_get_data_git: + vcs_info git: Compute %b correctly when merging to detached + heads. + 2015-09-30 Jun-ichi Takimoto * 36697: Completion/Base/Utility/_arguments: handle options diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git index 8ecc7c7f7..312f17c33 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git @@ -90,7 +90,7 @@ VCS_INFO_git_getbranch () { elif [[ -f "${gitdir}/MERGE_HEAD" ]] ; then gitbranch="$(${(z)gitsymref} 2> /dev/null)" - [[ -z ${gitbranch} ]] && gitbranch="$(< ${gitdir}/MERGE_HEAD)" + [[ -z ${gitbranch} ]] && gitbranch="$(< ${gitdir}/ORIG_HEAD)" elif [[ -d "${gitdir}/rebase-merge" ]] ; then gitbranch="$(< ${gitdir}/rebase-merge/head-name)" -- cgit v1.2.3 From cd1cda9d57ff9f44d285bcd867721c4024500837 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 30 Sep 2015 14:21:59 +0000 Subject: 36725: vcs_info git: Compute %b correctly when rebasing detached heads. This sets the %b expando to the hash of the before-the-merge HEAD, rather than to the literal string "detached HEAD". That hash is already available via the gen-applied-string hook. --- ChangeLog | 3 +++ Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 4 ++++ 2 files changed, 7 insertions(+) (limited to 'Functions/VCS_Info/Backends') diff --git a/ChangeLog b/ChangeLog index 9a755434a..f45b414c0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2015-09-30 Daniel Shahaf + * 36725: Functions/VCS_Info/Backends/VCS_INFO_get_data_git: + vcs_info git: Compute %b correctly when rebasing detached heads. + * 36725: Functions/VCS_Info/Backends/VCS_INFO_get_data_git: vcs_info git: Compute %b correctly when merging to detached heads. diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git index 312f17c33..0a2a8bc37 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git @@ -94,6 +94,10 @@ VCS_INFO_git_getbranch () { elif [[ -d "${gitdir}/rebase-merge" ]] ; then gitbranch="$(< ${gitdir}/rebase-merge/head-name)" + if [[ $gitbranch == 'detached HEAD' ]]; then + # get a sha1 + gitbranch="$(< ${gitdir}/rebase-merge/orig-head)" + fi elif [[ -d "${gitdir}/.dotest-merge" ]] ; then gitbranch="$(< ${gitdir}/.dotest-merge/head-name)" -- cgit v1.2.3 From a90cf551efc92184ab25da25b837296d1c4edc8a Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 30 Sep 2015 14:21:59 +0000 Subject: 36725: vcs_info git: Compute %b correctly when "git am"-ing onto detached heads. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this patch, $gitbranch would be set to empty, which caused VCS_INFO_get_data_git to early out with a failure status¹, consequently $vcs_info_msg_0_ would be empty. ¹ via the 'if [[ -z ]]' block around line 170. --- ChangeLog | 4 ++++ Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 1 + 2 files changed, 5 insertions(+) (limited to 'Functions/VCS_Info/Backends') diff --git a/ChangeLog b/ChangeLog index f45b414c0..20860a1f6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2015-09-30 Daniel Shahaf + * 36725: Functions/VCS_Info/Backends/VCS_INFO_get_data_git: + vcs_info git: Compute %b correctly when "git am"-ing onto + detached heads. + * 36725: Functions/VCS_Info/Backends/VCS_INFO_get_data_git: vcs_info git: Compute %b correctly when rebasing detached heads. diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git index 0a2a8bc37..8664d510e 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git @@ -87,6 +87,7 @@ VCS_INFO_git_getbranch () { gitbranch="$(${(z)gitsymref} 2> /dev/null)" [[ -z ${gitbranch} ]] && [[ -r ${actiondir}/head-name ]] \ && gitbranch="$(< ${actiondir}/head-name)" + [[ -z ${gitbranch} ]] && gitbranch="$(< ${gitdir}/ORIG_HEAD)" elif [[ -f "${gitdir}/MERGE_HEAD" ]] ; then gitbranch="$(${(z)gitsymref} 2> /dev/null)" -- cgit v1.2.3 From 7a1678767f44f200295d88dfea94902718275266 Mon Sep 17 00:00:00 2001 From: Frank Terbeck Date: Sun, 11 Oct 2015 11:54:06 +0200 Subject: 36830: vcs_info: Silence an error message with new git versions Mikael informs me on IRC, that in new versions of git (he used 2.6.1) where the "am" subcommand is now a builtin, a file that is used by the git backend of vcs_info (namely .git/rebase-apply/msg-clean) is not available anymore, leading to an annoying error message: VCS_INFO_get_data_git:232: no such file or directory: .git/rebase-apply/msg-clean This patch checks for the availabiliy of the file before using it, and adjusts the value of the dependant values accordingly. --- ChangeLog | 5 ++++ Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 34 +++++++++++++++-------- 2 files changed, 27 insertions(+), 12 deletions(-) (limited to 'Functions/VCS_Info/Backends') diff --git a/ChangeLog b/ChangeLog index 6369cf6e9..c8cad2adb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-10-11 Frank Terbeck + + * 36830: Functions/VCS_Info/Backends/VCS_INFO_get_data_git: + vcs_info: Silence an error message with new git versions + 2015-10-06 Peter Stephenson * 36780: Src/params.c: ensure HOME parameter is unset if diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git index 8664d510e..7fc213916 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git @@ -224,18 +224,28 @@ elif [[ -d "${gitdir}/rebase-apply" ]]; then patchdir="${gitdir}/rebase-apply" local next="${patchdir}/next" if [[ -f $next ]]; then - local cur=$(< $next) - local p subject - for p in $(seq $(($cur - 1))); do - git_patches_applied+=("$(printf "%04d" $p) ?") - done - subject="${$(< "${patchdir}/msg-clean")[(f)1]}" - if [[ -f "${patchdir}/original-commit" ]]; then - git_patches_applied+=("$(< ${patchdir}/original-commit) $subject") - else - git_patches_applied+=("? $subject") - fi - git_patches_unapplied=($(seq $cur $(< "${patchdir}/last"))) + local cur=$(< $next) + local p subject + for p in $(seq $(($cur - 1))); do + git_patches_applied+=("$(printf "%04d" $p) ?") + done + if [[ -f "${patchdir}/msg-clean" ]]; then + subject="${$(< "${patchdir}/msg-clean")[(f)1]}" + fi + if [[ -f "${patchdir}/original-commit" ]]; then + if [[ -n $subject ]]; then + git_patches_applied+=("$(< ${patchdir}/original-commit) $subject") + else + git_patches_applied+=("$(< ${patchdir}/original-commit)") + fi + else + if [[ -n $subject ]]; then + git_patches_applied+=("? $subject") + else + git_patches_applied+=("?") + fi + fi + git_patches_unapplied=($(seq $cur $(< "${patchdir}/last"))) fi VCS_INFO_git_handle_patches -- cgit v1.2.3 From e245dd71936d1c22fce39f02c203ed2cdb43a548 Mon Sep 17 00:00:00 2001 From: Frank Terbeck Date: Sun, 11 Oct 2015 12:39:56 +0200 Subject: 36832: vcs_info: Remove dependency on "seq" The "seq" utility is usually available on GNU systems only. This exchanges calls to seq with pure zsh features. Also: Less forks are good. --- ChangeLog | 3 +++ Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'Functions/VCS_Info/Backends') diff --git a/ChangeLog b/ChangeLog index c8cad2adb..be49cf526 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,9 @@ * 36830: Functions/VCS_Info/Backends/VCS_INFO_get_data_git: vcs_info: Silence an error message with new git versions + * 36832: Functions/VCS_Info/Backends/VCS_INFO_get_data_git: + vcs_info: Remove dependency on "seq" + 2015-10-06 Peter Stephenson * 36780: Src/params.c: ensure HOME parameter is unset if diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git index 7fc213916..fcee47c13 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git @@ -226,7 +226,7 @@ elif [[ -d "${gitdir}/rebase-apply" ]]; then if [[ -f $next ]]; then local cur=$(< $next) local p subject - for p in $(seq $(($cur - 1))); do + for ((p = 1; p < cur; p++)); do git_patches_applied+=("$(printf "%04d" $p) ?") done if [[ -f "${patchdir}/msg-clean" ]]; then @@ -245,7 +245,8 @@ elif [[ -d "${gitdir}/rebase-apply" ]]; then git_patches_applied+=("?") fi fi - git_patches_unapplied=($(seq $cur $(< "${patchdir}/last"))) + local last="$(< "${patchdir}/last")" + git_patches_unapplied=( {$cur..$last} ) fi VCS_INFO_git_handle_patches -- cgit v1.2.3 From f59864ce7a4a18efbfa5a330895d120ea1ce18f2 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Fri, 30 Oct 2015 15:08:53 +0000 Subject: 37025: vcs_info git: Add a cherry-pick patch-format --- ChangeLog | 5 +++++ Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) (limited to 'Functions/VCS_Info/Backends') diff --git a/ChangeLog b/ChangeLog index 46bb02f48..f314e82f4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-11-13 Daniel Shahaf + + * 37025: Functions/VCS_Info/Backends/VCS_INFO_get_data_git: + vcs_info git: Add a cherry-pick patch-format + 2015-11-13 Jun-ichi Takimoto * 37090: Doc/zman.yo, Doc/ztexi.yo: handle blank lines correctly diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git index fcee47c13..704c1890e 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git @@ -266,6 +266,28 @@ elif [[ -f "${gitdir}/MERGE_HEAD" ]]; then # Not touching git_patches_unapplied + VCS_INFO_git_handle_patches +elif [[ -f "${gitdir}/CHERRY_PICK_HEAD" ]]; then + # 'git cherry-pick' without -n, that conflicted. (With -n, git doesn't + # record the CHERRY_PICK_HEAD information anywhere, as of git 2.6.2.) + # + # ### 'git cherry-pick foo bar baz' only records the "remaining" part of + # ### the queue in the .git dir: if 'bar' has a conflict, the .git dir + # ### has a record of 'baz' being queued, but no record of 'foo' having been + # ### part of the queue as well. Therefore, the %n/%c applied/unapplied + # ### expandos will be memoryless: the "applied" counter will always + # ### be "1". The %u/%c tuple will assume the values [(1,2), (1,1), (1,0)], + # ### whereas the correct sequence would be [(1,2), (2,1), (3,0)]. + local subject + IFS='' read -r subject < "${gitdir}/MERGE_MSG" + git_patches_applied=( "$(<${gitdir}/CHERRY_PICK_HEAD) ${subject}" ) + if [[ -f "${gitdir}/sequencer/todo" ]]; then + # Get the next patches, and remove the one that's in CHERRY_PICK_HEAD. + git_patches_unapplied=( ${${(M)${(f)"$(<"${gitdir}/sequencer/todo")"}:#pick *}#pick } ) + git_patches_unapplied[1]=() + else + git_patches_unapplied=() + fi VCS_INFO_git_handle_patches else gitmisc='' -- cgit v1.2.3