1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2026-01-03 20:51:07 +01:00

41565: vcs_info patch2subject: Support svn log -r N --diff output.

This commit is contained in:
Daniel Shahaf 2017-08-17 17:26:39 +00:00
parent 1472c85412
commit d6aa949977
2 changed files with 14 additions and 2 deletions

View file

@ -6,14 +6,18 @@
integer -r LIMIT=10
local -a lines
local needle
readonly svn_log_pattern='^r[0-9]* [|] .*'
if [[ -f "$1" ]]; then
# Extract the first LIMIT lines, or up to the first empty line or the start of the unidiffs,
# whichever comes first.
while (( i++ < LIMIT )); do
IFS= read -r "lines[$i]"
if [[ -z ${lines[$i]} ]] || [[ ${lines[$i]} == (#b)(---|Index:)* ]]; then
if [[ -z ${lines[$i]} ]] || [[ ${lines[$i]} == (#b)(---[^-]|Index:)* ]]; then
lines[$i]=()
break
# For 'svn log -r N --diff' output, read the first paragraph too.
if ! [[ $lines[i-1] =~ $svn_log_pattern ]]; then
break
fi
fi
done < "$1"
@ -51,6 +55,9 @@
fi
} < "$1"
REPLY=$needle
elif [[ $lines[2] =~ $svn_log_pattern ]]; then
REPLY=$lines[4]
if (( ${+lines[5]} )); then REPLY+='...'; fi
elif (( ${+lines[1]} )); then
# The first line of the file is not part of the diff.
REPLY=${lines[1]}