diff options
author | Axel Beckert <abe@deuxchevaux.org> | 2020-02-14 01:58:20 +0100 |
---|---|---|
committer | Axel Beckert <abe@deuxchevaux.org> | 2020-02-14 01:58:20 +0100 |
commit | bfc5d42735c1660263904ec5254cccf539a0a458 (patch) | |
tree | 9bbb81b4a53941427e6f9e65ae55027d9108df8c /Functions/VCS_Info | |
parent | 74561cc51b8867e43cb2937ab2edfb36e2a829bf (diff) | |
parent | 643de931640e01aa246723d2038328ef33737965 (diff) | |
download | zsh-bfc5d42735c1660263904ec5254cccf539a0a458.tar.gz zsh-bfc5d42735c1660263904ec5254cccf539a0a458.zip |
Merge tag 'zsh-5.7.1-test-3' into debian
Test release: 5.7.1-test-3
Diffstat (limited to 'Functions/VCS_Info')
-rw-r--r-- | Functions/VCS_Info/Backends/VCS_INFO_detect_git | 3 | ||||
-rw-r--r-- | Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs | 12 | ||||
-rw-r--r-- | Functions/VCS_Info/Backends/VCS_INFO_get_data_svn | 12 | ||||
-rw-r--r-- | Functions/VCS_Info/VCS_INFO_bydir_detect | 12 | ||||
-rw-r--r-- | Functions/VCS_Info/VCS_INFO_patch2subject | 20 | ||||
-rw-r--r-- | Functions/VCS_Info/VCS_INFO_quilt | 10 | ||||
-rw-r--r-- | Functions/VCS_Info/vcs_info | 6 |
7 files changed, 53 insertions, 22 deletions
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_detect_git b/Functions/VCS_Info/Backends/VCS_INFO_detect_git index 61bc483e3..e4191f474 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_detect_git +++ b/Functions/VCS_Info/Backends/VCS_INFO_detect_git @@ -6,8 +6,7 @@ setopt localoptions NO_shwordsplit [[ $1 == '--flavours' ]] && { print -l git-p4 git-svn; return 0 } -if VCS_INFO_check_com ${vcs_comm[cmd]} && ${vcs_comm[cmd]} rev-parse --is-inside-work-tree &> /dev/null ; then - vcs_comm[gitdir]="$(${vcs_comm[cmd]} rev-parse --git-dir 2> /dev/null)" || return 1 +if VCS_INFO_check_com ${vcs_comm[cmd]} && vcs_comm[gitdir]="$(${vcs_comm[cmd]} rev-parse --git-dir 2> /dev/null)" ; then if [[ -d ${vcs_comm[gitdir]}/svn ]] ; then vcs_comm[overwrite_name]='git-svn' elif [[ -d ${vcs_comm[gitdir]}/refs/remotes/p4 ]] ; then vcs_comm[overwrite_name]='git-p4' ; fi return 0 diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs b/Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs index e9d172052..9b828bd11 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs @@ -5,11 +5,17 @@ setopt localoptions NO_shwordsplit local cvsbranch cvsbase +# Look for the most distant parent that still has a CVS subdirectory. +# VCS_INFO_detect_cvs ensured that ./CVS/Repository exists. cvsbase="." -while [[ -d "${cvsbase}/../CVS" ]]; do - cvsbase="${cvsbase}/.." -done cvsbase=${cvsbase:P} +while [[ -d "${cvsbase:h}/CVS" ]]; do + cvsbase="${cvsbase:h}" + if [[ $cvsbase == '/' ]]; then + break + fi +done + cvsbranch=$(< ./CVS/Repository) rrn=${cvsbase:t} cvsbranch=${cvsbranch##${rrn}/} diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn b/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn index c1547950f..21590addd 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn @@ -46,17 +46,19 @@ if (( ${+svninfo[Working_Copy_Root_Path]} )); then ${vcs_comm[cmd]} info --non-interactive -- "${svnbase}" | while IFS=: read a b; do svninfo[${a// /_}]="${b## #}"; done else # svn 1.0-1.6 - while [[ -d "${svnbase}/../.svn" ]]; do + svnbase=${svnbase:P} + while [[ -d "${svnbase:h}/.svn" ]]; do parentinfo=() - ${vcs_comm[cmd]} info --non-interactive -- "${svnbase}/.." | while IFS=: read a b; do parentinfo[${a// /_}]="${b## #}"; done + ${vcs_comm[cmd]} info --non-interactive -- "${svnbase:h}" | while IFS=: read a b; do parentinfo[${a// /_}]="${b## #}"; done [[ ${parentinfo[Repository_UUID]} != ${svninfo[Repository_UUID]} ]] && break svninfo=(${(kv)parentinfo}) - svnbase="${svnbase}/.." + svnbase=${svnbase:h} + if [[ $svnbase == '/' ]]; then + break + fi done fi -svnbase=${svnbase:P} - rrn=${svnbase:t} zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" branchformat svnbranch || svnbranch="%b:%r" hook_com=( branch "${svninfo[URL]##*/}" revision "${cwdinfo[Revision]}" ) diff --git a/Functions/VCS_Info/VCS_INFO_bydir_detect b/Functions/VCS_Info/VCS_INFO_bydir_detect index b20c05c9c..29b261413 100644 --- a/Functions/VCS_Info/VCS_INFO_bydir_detect +++ b/Functions/VCS_Info/VCS_INFO_bydir_detect @@ -2,6 +2,18 @@ ## Written by Frank Terbeck <ft@bewatermyfriend.org> ## Distributed under the same BSD-ish license as zsh itself. +# Helper function for VCS_INFO_detect_* +# +# Usage: +# vcs_comm[detect_need_file]=FILENAMES VCS_INFO_bydir_detect DIRNAME +# where DIRNAME is a directory name and FILENAMES is a space-separated list +# of filenames. +# +# If any parent directory of the current working directory, other than the root +# directory, contains a subdirectory named DIRNAME that contains a file whose name +# is in FILENAMES, set vcs_comm[basedir] to the path of that parent directory and +# return true. Otherwise, return false. + setopt localoptions NO_shwordsplit local dirname=$1 local basedir="." file diff --git a/Functions/VCS_Info/VCS_INFO_patch2subject b/Functions/VCS_Info/VCS_INFO_patch2subject index a48c16b04..a467edcdb 100644 --- a/Functions/VCS_Info/VCS_INFO_patch2subject +++ b/Functions/VCS_Info/VCS_INFO_patch2subject @@ -14,10 +14,7 @@ IFS= read -r "lines[$i]" if [[ -z ${lines[$i]} ]] || [[ ${lines[$i]} == (#b)(---[^-]|Index:)* ]]; then lines[$i]=() - # For 'svn log -r N --diff' output, read the first paragraph too. - if ! [[ $lines[i-1] =~ $svn_log_pattern ]]; then - break - fi + break fi done < "$1" @@ -55,9 +52,18 @@ fi } < "$1" REPLY=$needle - elif [[ $lines[2] =~ $svn_log_pattern ]]; then - REPLY=$lines[4] - if (( ${+lines[5]} )); then REPLY+='...'; fi + elif [[ $lines[1] =~ $svn_log_pattern ]] || [[ $lines[2] =~ $svn_log_pattern ]]; then + # Read up to the next blank line, and the first two lines after it. + integer multiline=0 + { + while read -r needle; [[ -n $needle ]]; do done + # Read the first line of the second paragraph, which is the first + # line of the log message. + read -r needle + read -r && [[ -n $REPLY ]] && multiline=1 + } < "$1" + REPLY=$needle + if (( multiline )); then REPLY+='...'; fi elif (( ${+lines[1]} )); then # The first line of the file is not part of the diff. REPLY=${lines[1]} diff --git a/Functions/VCS_Info/VCS_INFO_quilt b/Functions/VCS_Info/VCS_INFO_quilt index 1f20e895d..fef85964a 100644 --- a/Functions/VCS_Info/VCS_INFO_quilt +++ b/Functions/VCS_Info/VCS_INFO_quilt @@ -78,7 +78,7 @@ function VCS_INFO_quilt-dirfind() { VCS_INFO_bydir_detect ${dir} ret=$? vcs_comm[detect_need_file]=${oldfile} - printf '%s' ${vcs_comm[basedir]} + REPLY=${vcs_comm[basedir]} vcs_comm[basedir]="${olddir}" return ${ret} } @@ -113,8 +113,8 @@ function VCS_INFO_quilt-patch2subject() { ;; esac - pc="$(VCS_INFO_quilt-dirfind .pc .version)" - ret=$? + VCS_INFO_quilt-dirfind .pc .version + ret=$? pc=$REPLY if (( ret == 0 )); then [[ ${quiltmode} == 'standalone' ]] && root=${pc} pc=${pc}/.pc @@ -138,8 +138,8 @@ function VCS_INFO_quilt-patch2subject() { zstyle -s "${context}" quilt-patch-dir patches || patches="${QUILT_PATCHES}" if [[ "${patches}" != /* ]]; then tmp=${patches:-patches} - patches="$(VCS_INFO_quilt-dirfind "${tmp}")" - ret=$? + VCS_INFO_quilt-dirfind "${tmp}" + ret=$? patches=$REPLY (( ret )) && return ${ret} patches=${patches}/${tmp} else diff --git a/Functions/VCS_Info/vcs_info b/Functions/VCS_Info/vcs_info index d67ae6bf5..9f48bee75 100644 --- a/Functions/VCS_Info/vcs_info +++ b/Functions/VCS_Info/vcs_info @@ -59,6 +59,12 @@ vcs_info () { local -x LC_MESSAGES local -i maxexports local -a msgs + + # vcs_comm is used internally for passing values among VCS_INFO_* functions. + # It is not part of the public API. + # + # hook_com, backend_misc, and user_data are public API; see zshcontrib(1) + # and Misc/vcs_info-examples. local -A vcs_comm hook_com backend_misc user_data LC_MESSAGES=C |