From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Subject: [PATCH] vcs_info patch2subject: Support `git show` output.
Date: Sat, 21 Jan 2017 12:12:31 +0000 [thread overview]
Message-ID: <1485000751-24044-1-git-send-email-danielsh@fujitsu.shahaf.local2> (raw)
---
Personally I'd have used a Unicode ellipsis (…) instead of an ASCII one
in the «needle+=» line, but it's only 2017...
Cheers,
Daniel
Functions/VCS_Info/VCS_INFO_patch2subject | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/Functions/VCS_Info/VCS_INFO_patch2subject b/Functions/VCS_Info/VCS_INFO_patch2subject
index 583467b..bbd3c8d 100644
--- a/Functions/VCS_Info/VCS_INFO_patch2subject
+++ b/Functions/VCS_Info/VCS_INFO_patch2subject
@@ -1,6 +1,7 @@
# 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.
{
+ setopt localoptions extendedglob
integer i
integer -r LIMIT=10
local -a lines
@@ -34,6 +35,22 @@
elif [[ ${lines[1]} == '# HG changeset patch' ]] && { needle=${${lines:#([#]*)}[1]}; [[ -n $needle ]] }; then
# Mercurial patch
REPLY=$needle
+ elif [[ ${lines[1]} == "commit "[0-9a-f](#c40) ]] &&
+ [[ ${lines[2]} == "Author:"* && ${lines[3]} == "Date:"* ]] &&
+ (( ! ${+lines[4]} )); then
+ # `git show` output.
+ #
+ # The log message is after the first blank line, so open() the file
+ # again. Also check whether the following line (second line of the
+ # log message itself) is empty.
+ {
+ repeat 4 { IFS= read -r }
+ IFS= read -r needle; needle=${needle#' '}
+ if IFS= read -r; REPLY=${REPLY#' '}; [[ -n $REPLY ]]; then
+ needle+='...'
+ fi
+ } < "$1"
+ REPLY=$needle
elif (( ${+lines[1]} )); then
# The first line of the file is not part of the diff.
REPLY=${lines[1]}
reply other threads:[~2017-01-21 12:16 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1485000751-24044-1-git-send-email-danielsh@fujitsu.shahaf.local2 \
--to=d.s@daniel.shahaf.name \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).