From ccf50048ac5bbef3f66164bd420d7c178ddd53ad Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 20 Nov 2016 02:21:39 +0100 Subject: Get subject of current patch in rebase-apply mode --- Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'Functions') diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git index 18ba89a9a..1560d7f27 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git @@ -236,6 +236,15 @@ elif [[ -d "${gitdir}/rebase-apply" ]]; then done if [[ -f "${patchdir}/msg-clean" ]]; then subject="${$(< "${patchdir}/msg-clean")[(f)1]}" + elif [[ -f "${patchdir}/${(l:4::0:)cur}" ]]; then + local maxlines=10 line + while IFS= read -r line; do + if [[ "$line" == "Subject:"* ]]; then + subject=${line/(#s)Subject: /} + break + fi + (( --maxlines )) || break + done < "${patchdir}/${(l:4::0:)cur}" fi if [[ -f "${patchdir}/original-commit" ]]; then if [[ -n $subject ]]; then -- cgit v1.2.3 From d9237ccdbfb0f24ca40fead41de79e13b5f712be Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Sat, 3 Dec 2016 10:34:46 +0000 Subject: 40074: vcs_info git: rfc822-unfold rebase-apply patch subjects when msg-clean is unavailable. Example (in this repository): git -c merge.merge-changelog.driver=/bin/false rebase --onto=1955cce^^ 1955cce^ 1955cce --- ChangeLog | 6 ++++++ Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 15 +++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) (limited to 'Functions') diff --git a/ChangeLog b/ChangeLog index 0ff1565e0..05e39d2d1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2016-12-04 Daniel Shahaf + + * 40074: Functions/VCS_Info/Backends/VCS_INFO_get_data_git: + vcs_info git: rfc822-unfold rebase-apply patch subjects when + msg-clean is unavailable. + 2016-12-04 Peter Stephenson * 40088: Test/D04parameter.ztst: attempt to make output from diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git index 1560d7f27..a92261fa3 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git @@ -237,14 +237,11 @@ elif [[ -d "${gitdir}/rebase-apply" ]]; then if [[ -f "${patchdir}/msg-clean" ]]; then subject="${$(< "${patchdir}/msg-clean")[(f)1]}" elif [[ -f "${patchdir}/${(l:4::0:)cur}" ]]; then - local maxlines=10 line - while IFS= read -r line; do - if [[ "$line" == "Subject:"* ]]; then - subject=${line/(#s)Subject: /} - break - fi - (( --maxlines )) || break - done < "${patchdir}/${(l:4::0:)cur}" + () { + local REPLY + VCS_INFO_patch2subject "${patchdir}/${(l:4::0:)cur}" + subject=$REPLY + } fi if [[ -f "${patchdir}/original-commit" ]]; then if [[ -n $subject ]]; then @@ -270,6 +267,7 @@ elif [[ -f "${gitdir}/MERGE_HEAD" ]]; then # This is 'git merge --no-commit' local -a heads=( ${(@f)"$(<"${gitdir}/MERGE_HEAD")"} ) local subject; + # TODO: maybe read up to the first blank line IFS='' read -r subject < "${gitdir}/MERGE_MSG" # $subject is the subject line of the would-be commit # Maybe we can get the subject lines of MERGE_HEAD's commits cheaply? @@ -295,6 +293,7 @@ elif [[ -f "${gitdir}/CHERRY_PICK_HEAD" ]]; then # ### 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 + # TODO: maybe read up to the first blank line IFS='' read -r subject < "${gitdir}/MERGE_MSG" git_patches_applied=( "$(<${gitdir}/CHERRY_PICK_HEAD) ${subject}" ) if [[ -f "${gitdir}/sequencer/todo" ]]; then -- cgit v1.2.3 From f71de84f1d9f7c2d63226a2e5534fc12d05ec716 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Sat, 3 Dec 2016 13:52:00 +0000 Subject: unposted: vcs_info git: Handle rebase-apply sequences with >=10000 patches. Review-by: Frank Terbeck --- ChangeLog | 3 +++ Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'Functions') diff --git a/ChangeLog b/ChangeLog index 05e39d2d1..67f8c7687 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2016-12-04 Daniel Shahaf + * unposted: Functions/VCS_Info/Backends/VCS_INFO_get_data_git: + vcs_info git: Handle rebase-apply sequences with >=10000 patches. + * 40074: Functions/VCS_Info/Backends/VCS_INFO_get_data_git: vcs_info git: rfc822-unfold rebase-apply patch subjects when msg-clean is unavailable. diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git index a92261fa3..65d8cb182 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git @@ -232,14 +232,17 @@ elif [[ -d "${gitdir}/rebase-apply" ]]; then local cur=$(< $next) local p subject for ((p = 1; p < cur; p++)); do - git_patches_applied+=("$(printf "%04d" $p) ?") + printf -v "git_patches_applied[$p]" "%04d ?" "$p" done if [[ -f "${patchdir}/msg-clean" ]]; then subject="${$(< "${patchdir}/msg-clean")[(f)1]}" - elif [[ -f "${patchdir}/${(l:4::0:)cur}" ]]; then + elif local this_patch_file + printf -v this_patch_file "%s/%04d" "${patchdir}" "${cur}" + [[ -f $this_patch_file ]] + then () { local REPLY - VCS_INFO_patch2subject "${patchdir}/${(l:4::0:)cur}" + VCS_INFO_patch2subject "${this_patch_file}" subject=$REPLY } fi -- cgit v1.2.3