* [PATCH 1/3] vcs_info git: In non-interactive rebases, compute patch names for unapplied patches.
@ 2020-03-12 18:06 Daniel Shahaf
2020-03-12 18:06 ` [PATCH 2/3] vcs_info git: In non-interactive rebases, obtain applied patches' names Daniel Shahaf
2020-03-12 18:06 ` [PATCH 3/3] internal: vcs_info git: Add a test case repository for rebase-apply situations Daniel Shahaf
0 siblings, 2 replies; 3+ messages in thread
From: Daniel Shahaf @ 2020-03-12 18:06 UTC (permalink / raw)
To: zsh-workers
---
Doc/Zsh/contrib.yo | 4 +--
.../VCS_Info/Backends/VCS_INFO_get_data_git | 31 +++++++++++++++----
2 files changed, 27 insertions(+), 8 deletions(-)
diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo
index c6bf745b7..0909cd4f5 100644
--- a/Doc/Zsh/contrib.yo
+++ b/Doc/Zsh/contrib.yo
@@ -1177,7 +1177,7 @@ If there are two different ways of gathering
information, you can select the simpler one by setting this style to true;
the default is to use the not-that-simple code, which is potentially a lot
slower but might be more accurate in all possible cases. This style is
-used by the tt(bzr) and tt(hg) backends. In the case of tt(hg) it will invoke
+used by the tt(bzr), tt(hg), and tt(git) backends. In the case of tt(hg) it will invoke
the external hexdump program to parse the binary dirstate cache file; this
method will not return the local revision number.
)
@@ -1236,7 +1236,7 @@ item(tt(get-unapplied))(
This boolean style controls whether a backend should attempt to gather a list
of unapplied patches (for example with Mercurial Queue patches).
-Used by the tt(quilt) and tt(hg) backends.
+Used by the tt(quilt), tt(hg), and tt(git) backends.
)
enditem()
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index 5ddce72a6..6391cd1a6 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -248,17 +248,20 @@ elif [[ -d "${gitdir}/rebase-apply" ]]; then
# 'git rebase' without -i
patchdir="${gitdir}/rebase-apply"
local next="${patchdir}/next"
+ local this_patch_file
if [[ -f $next ]]; then
local cur=$(< $next)
local p subject
- # Fake patch names for all but current patch
+ # Fake patch names for patches "before" the current patch
+ #
+ # Note: With git 2.24, (( cur == 1 )), so the loop body never runs.
for ((p = 1; p < cur; p++)); do
printf -v "git_patches_applied[$p]" "%04d ?" "$p"
done
+ # Set $subject to the info for the current patch
if [[ -f "${patchdir}/msg-clean" ]]; then
subject="${$(< "${patchdir}/msg-clean")[(f)1]}"
- elif local this_patch_file
- printf -v this_patch_file "%s/%04d" "${patchdir}" "${cur}"
+ elif printf -v this_patch_file "%s/%04d" "${patchdir}" "${cur}"
[[ -f $this_patch_file ]]
then
() {
@@ -273,11 +276,27 @@ elif [[ -d "${gitdir}/rebase-apply" ]]; then
else
git_patches_applied+=("? $subject")
fi
- local last="$(< "${patchdir}/last")"
- if (( cur+1 <= last )); then
- git_patches_unapplied=( {$((cur+1))..$last} )
+ # Handle patches scheduled for after the current patch, if instructed to.
+ if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" get-unapplied; then
+ local last="$(< "${patchdir}/last")"
+ if [[ -r ${patchdir}/original-commit && -r ${patchdir}/orig-head ]] &&
+ ! zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" use-simple
+ then
+ git_patches_unapplied+=( ${(f)"$(${vcs_comm[cmd]} log --reverse --pretty="%h %s" "$(<${patchdir}/original-commit)..$(<${patchdir}/orig-head)")"} )
+ else
+ for ((p = cur+1; p <= last; p++)); do
+ printf -v this_patch_file "%s/%04d" "${patchdir}" "${p}"
+ if [[ -f $this_patch_file ]]; then
+ VCS_INFO_patch2subject "${this_patch_file}"
+ git_patches_unapplied+=( "$p $REPLY" )
+ else
+ git_patches_unapplied+=( "$p ?" )
+ fi
+ done
+ fi
fi
fi
+ unset this_patch_file
VCS_INFO_git_handle_patches
elif [[ -f "${gitdir}/MERGE_HEAD" ]]; then
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/3] vcs_info git: In non-interactive rebases, obtain applied patches' names.
2020-03-12 18:06 [PATCH 1/3] vcs_info git: In non-interactive rebases, compute patch names for unapplied patches Daniel Shahaf
@ 2020-03-12 18:06 ` Daniel Shahaf
2020-03-12 18:06 ` [PATCH 3/3] internal: vcs_info git: Add a test case repository for rebase-apply situations Daniel Shahaf
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Shahaf @ 2020-03-12 18:06 UTC (permalink / raw)
To: zsh-workers
---
.../VCS_Info/Backends/VCS_INFO_get_data_git | 22 ++++++++++++++-----
1 file changed, 17 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 6391cd1a6..4731c7400 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -253,11 +253,23 @@ elif [[ -d "${gitdir}/rebase-apply" ]]; then
local cur=$(< $next)
local p subject
# Fake patch names for patches "before" the current patch
- #
- # Note: With git 2.24, (( cur == 1 )), so the loop body never runs.
- for ((p = 1; p < cur; p++)); do
- printf -v "git_patches_applied[$p]" "%04d ?" "$p"
- done
+ if [[ -r ${patchdir}/rewritten ]]; then
+ if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" use-simple; then
+ git_patches_applied=( ${${(f)"$(<${patchdir}/rewritten)"}// */' ?'} )
+ else
+ git_patches_applied=(
+ ${(f)"$(${vcs_comm[cmd]} log --no-walk=unsorted --pretty='%h %s' ${${(f)"$(<${patchdir}/rewritten)"}%% *} --)"}
+ )
+ fi
+ else
+ # Compatibility with old git. In 2.11 and 2.24, at least,
+ # (( cur == 1 )), so the loop body would never run. However, both
+ # of these versions have original-commit and orig-head and would
+ # take the 'if' branch, rather than this 'else' branch.
+ for ((p = 1; p < cur; p++)); do
+ printf -v "git_patches_applied[$p]" "%04d ?" "$p"
+ done
+ fi
# Set $subject to the info for the current patch
if [[ -f "${patchdir}/msg-clean" ]]; then
subject="${$(< "${patchdir}/msg-clean")[(f)1]}"
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 3/3] internal: vcs_info git: Add a test case repository for rebase-apply situations
2020-03-12 18:06 [PATCH 1/3] vcs_info git: In non-interactive rebases, compute patch names for unapplied patches Daniel Shahaf
2020-03-12 18:06 ` [PATCH 2/3] vcs_info git: In non-interactive rebases, obtain applied patches' names Daniel Shahaf
@ 2020-03-12 18:06 ` Daniel Shahaf
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Shahaf @ 2020-03-12 18:06 UTC (permalink / raw)
To: zsh-workers
---
Functions/VCS_Info/test-repo-git-rebase-apply | 49 +++++++++++++++++++
1 file changed, 49 insertions(+)
create mode 100755 Functions/VCS_Info/test-repo-git-rebase-apply
diff --git a/Functions/VCS_Info/test-repo-git-rebase-apply b/Functions/VCS_Info/test-repo-git-rebase-apply
new file mode 100755
index 000000000..cb4ea4f58
--- /dev/null
+++ b/Functions/VCS_Info/test-repo-git-rebase-apply
@@ -0,0 +1,49 @@
+#!/usr/local/bin/zsh -f
+#
+# This script creates a test repository for testing the git backend's behaviour during rebase-apply operations.
+#
+# It works in ./vcs-test/.
+#
+# Suggested zshrc settings:
+#
+# autoload vcs_info
+# precmd() { vcs_info; typeset -pm vcs\* }
+# zstyle ':vcs_info:*' actionformats %m
+# zstyle ':vcs_info:*' patch-format '[%n+%c=%a] [%p] [%u]'
+# zstyle :vcs_info:\*gen-applied-string\* hooks f1
+# +vi-f1() { typeset -p argv hook_com }
+# zstyle :vcs_info:\*gen-unapplied-string\* hooks f2
+# +vi-f2() { typeset -p argv hook_com }
+# zstyle :vcs_info:\* get-unapplied true
+#
+mkdir "vcs-test"
+cd "vcs-test"
+git init
+
+append_lines() { for 1; do echo line from r$1 >> iota && git commit -am "r$1: Append a line"; done }
+
+echo "This is the file 'iota'." > iota
+git add iota
+git commit -m "r1: Add iota"
+git tag rebase_onto_this HEAD
+
+# Make another change to iota
+append_lines 2
+git tag rebase_from_this HEAD
+
+# Make non-conflicting changes
+for 1 in 3 4 5 6; do
+ touch kappa$1
+ git add kappa$1
+ git commit -m "r${1}: non-conflicting change"
+done
+
+# Make more changes to iota
+append_lines 7 8 9
+
+# Specify a rebase that would create the history [1,3,4,5,6,7,8,9].
+# This will conflict because r7 depends on r2 which is not included.
+git checkout -b myref
+git rebase --onto=rebase_onto_this rebase_from_this myref
+
+
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-03-12 18:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-12 18:06 [PATCH 1/3] vcs_info git: In non-interactive rebases, compute patch names for unapplied patches Daniel Shahaf
2020-03-12 18:06 ` [PATCH 2/3] vcs_info git: In non-interactive rebases, obtain applied patches' names Daniel Shahaf
2020-03-12 18:06 ` [PATCH 3/3] internal: vcs_info git: Add a test case repository for rebase-apply situations Daniel Shahaf
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).