From: Jeremiah Mahler <jmmahler@gmail.com>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v5] format-patch --signature-file <file>
Date: Tue, 20 May 2014 17:42:44 -0700 [thread overview]
Message-ID: <20140521004244.GA4927@hudson.localdomain> (raw)
In-Reply-To: <20140520082740.GB27590@sigill.intra.peff.net>
On Tue, May 20, 2014 at 04:27:40AM -0400, Jeff King wrote:
> On Tue, May 20, 2014 at 01:00:06AM -0700, Jeremiah Mahler wrote:
>
...
> > +test_expect_success 'format-patch --signature-file=file' '
> > + git format-patch --stdout --signature-file=expect -1 >output &&
> > + check_patch output &&
> > + sed -n -e "/^-- $/,\$p" <output | sed -e "1 d" | sed -e "\$d" | sed -e "\$d" >output2 &&
> > + test_cmp expect output2
> > +'
>
> Here we drop two final lines from the email output. But if I just use
> vanilla git and try this, I get nothing:
>
> $ git format-patch -1 --stdout |
> sed -n -e "/^-- $/,\$p" | sed -e "1 d" | sed -e "\$d" | sed -e "\$d"
>
> Removing the second dropped line works:
>
> $ git format-patch -1 --stdout |
> sed -n -e "/^-- $/,\$p" | sed -e "1 d" | sed -e "\$d"
> 2.0.0.rc1.436.g03cb729
>
> I guess the signature code is adding its own newline, so that the
> default signature (or "--signature=foo") works. But it adds it
> unconditionally, which is probably not what we want for signatures read
> from a file.
>
> Do we maybe want something like this right before your patch?
>
> -- >8 --
> Subject: format-patch: make newline after signature conditional
>
> When we print an email signature, we print the divider "--
> \n", then the signature string, then two newlines.
> Traditionally the signature is a one-liner (and the default
> is just the git version), so the extra newline makes sense.
>
> But one could easily specify a longer, multi-line signature,
> like:
>
> git format-patch --signature='
> this is my long signature
>
> it has multiple lines
> ' ...
>
> We should notice that it already has its own trailing
> newline, and suppress one of ours.
>
> Signed-off-by: Jeff King <peff@peff.net>
> ---
> In the example above, there's also a newline before the signature
> starts. Should we suppress the first one, too?
>
> Also, I'm not clear on the purpose of the extra trailing line in the
> first place. Emails now end with (">" added to show blanks):
>
> > --
> > 2.0.0-rc3...
> >
>
> Is there are a reason for that final blank line?
>
> builtin/log.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/builtin/log.c b/builtin/log.c
> index 39e8836..5acc048 100644
> --- a/builtin/log.c
> +++ b/builtin/log.c
> @@ -844,8 +844,13 @@ static void gen_message_id(struct rev_info *info, char *base)
>
> static void print_signature(void)
> {
> - if (signature && *signature)
> - printf("-- \n%s\n\n", signature);
> + if (!signature || !*signature)
> + return;
> +
> + printf("-- \n%s", signature);
> + if (signature[strlen(signature)-1] != '\n')
> + putchar('\n');
> + putchar('\n');
> }
>
> static void add_branch_description(struct strbuf *buf, const char *branch_name)
> --
> 2.0.0.rc1.436.g03cb729
>
The simple solution, leaving things as they are, appeals to me.
For the purposes of testing just expect whatever odd number of blank
lines are produced. Or perhaps slurp all the trailing blank lines and
then compare.
It would be nice if every signature was followed by exactly one blank line.
But if it had two it wouldn't bother me much.
--
Jeremiah Mahler
jmmahler@gmail.com
http://github.com/jmahler
prev parent reply other threads:[~2014-05-21 0:42 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-20 8:00 [PATCH v5] format-patch --signature-file <file> Jeremiah Mahler
2014-05-20 8:00 ` Jeremiah Mahler
2014-05-20 8:27 ` Jeff King
2014-05-20 17:53 ` Junio C Hamano
2014-05-20 18:24 ` Jeff King
2014-05-20 18:46 ` Junio C Hamano
2014-05-21 16:42 ` Jeff King
2014-05-21 16:55 ` Jeremiah Mahler
2014-05-21 17:00 ` Jeff King
2014-05-21 17:37 ` Junio C Hamano
2014-05-21 17:59 ` Jeff King
2014-05-21 18:26 ` Junio C Hamano
2014-05-21 20:47 ` Jeff King
2014-05-21 21:14 ` Jeremiah Mahler
2014-05-21 0:42 ` Jeremiah Mahler [this message]
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=20140521004244.GA4927@hudson.localdomain \
--to=jmmahler@gmail.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
/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.
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).