diff options
author | Daniel Shahaf <d.s@daniel.shahaf.name> | 2016-06-04 16:57:48 +0000 |
---|---|---|
committer | Daniel Shahaf <d.s@daniel.shahaf.name> | 2016-06-06 08:10:11 +0000 |
commit | e8943e7007d27143d17cf66acf659e92fcea1fe9 (patch) | |
tree | e22b00c3fa4f914fd41acadb511f139f0fe7f8ed | |
parent | 8cca44482481eb4a91d2cae60f9c207a296a7d50 (diff) | |
download | zsh-e8943e7007d27143d17cf66acf659e92fcea1fe9.tar.gz zsh-e8943e7007d27143d17cf66acf659e92fcea1fe9.tar.xz zsh-e8943e7007d27143d17cf66acf659e92fcea1fe9.zip |
38609: vcs_info quilt: Factor out a helper function. No functional change.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | Functions/VCS_Info/VCS_INFO_quilt | 35 |
2 files changed, 27 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog index d79ebc235..5f0cae6ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2016-06-06 Daniel Shahaf <d.s@daniel.shahaf.name> + + * 38609: Functions/VCS_Info/VCS_INFO_quilt: vcs_info quilt: + Factor out a helper function. No functional change. + 2016-06-05 Barton E. Schaefer <schaefer@zsh.org> * 38622: Src/jobs.c: consistent handling of "--" in "kill" builtin diff --git a/Functions/VCS_Info/VCS_INFO_quilt b/Functions/VCS_Info/VCS_INFO_quilt index c3c3d864d..e31deb0bd 100644 --- a/Functions/VCS_Info/VCS_INFO_quilt +++ b/Functions/VCS_Info/VCS_INFO_quilt @@ -80,6 +80,23 @@ function VCS_INFO_quilt-dirfind() { return ${ret} } +# This function takes as an argument a filename of a patch and sets $REPLY to +# a single-line "subject", or unsets it if no subject could be extracted. +function VCS_INFO_quilt-patch2subject() { + local line + if [[ -f "$1" ]] && read -r line < "$1"; then + if [[ $line != (#b)(---|Index:)* ]]; then + REPLY=$line + else + unset REPLY + return 0 + fi + else + unset REPLY + return 1 + fi +} + function VCS_INFO_quilt() { emulate -L zsh setopt extendedglob @@ -147,27 +164,19 @@ function VCS_INFO_quilt() { if [[ -n $patches ]]; then () { - local i line + local i for ((i=1; i<=$#applied; i++)); do - if [[ -f "$patches/$applied[$i]" ]] && - read -r line < "$patches/$applied[$i]" && - [[ $line != (#b)(---|Index:)* ]] && - true - ; + if VCS_INFO_quilt-patch2subject "$patches/$applied[$i]" && (( $+REPLY )) then - applied[$i]+=" $line" + applied[$i]+=" $REPLY" else applied[$i]+=" ?" fi done for ((i=1; i<=$#unapplied; i++)); do - if [[ -f "$patches/$unapplied[$i]" ]] && - read -r line < "$patches/$unapplied[$i]" && - [[ $line != (#b)(---|Index:)* ]] && - true - ; + if VCS_INFO_quilt-patch2subject "$patches/$unapplied[$i]" && (( $+REPLY )) then - unapplied[$i]+=" $line" + unapplied[$i]+=" $REPLY" else unapplied[$i]+=" ?" fi |