From: Jeff King <peff@peff.net>
To: Jeremiah Mahler <jmmahler@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v4] format-patch --signature-file <file>
Date: Mon, 19 May 2014 06:48:11 -0400 [thread overview]
Message-ID: <20140519104810.GA17492@sigill.intra.peff.net> (raw)
In-Reply-To: <1400444522-15523-2-git-send-email-jmmahler@gmail.com>
On Sun, May 18, 2014 at 01:22:02PM -0700, Jeremiah Mahler wrote:
> @@ -742,6 +743,8 @@ static int git_format_config(const char *var, const char *value, void *cb)
> }
> if (!strcmp(var, "format.signature"))
> return git_config_string(&signature, var, value);
> + if (!strcmp(var, "format.signaturefile"))
> + return git_config_string(&signature_file, var, value);
Should this be git_config_pathname? That would handle tilde-expansion.
> +test_expect_success 'format-patch --signature-file=file' '
> + git format-patch --stdout --signature-file=expect -1 >output &&
> + check_patch output &&
> + sed -n "/^-- $/,\$p" <output | head --lines=-2 | tail --lines=+2 >output2 &&
> + test_cmp expect output2
> +'
I don't think --lines is portable (it's not even POSIX), nor is a
negative value for head (but a "+" form for tail is). You can replace
the "head" call with a "$d" sed command, and tail should be fine with
"-n +2". Like:
sed -n '$d; /^-- $/,$p' | tail -n +2
You can also do it in one sed like:
sed -n '$d; /^-- $/,${//!p}'
but that is starting to look a bit like line-noise. ;)
> +test_expect_success 'format-patch with format.signaturefile config' '
> + git config format.signaturefile expect &&
> + git format-patch --stdout -1 >output &&
> + check_patch output &&
> + sed -n "/^-- $/,\$p" <output | head --lines=-2 | tail --lines=+2 >output2 &&
> + test_cmp expect output2 &&
> + git config --unset-all format.signaturefile
> +'
You might want to use "test_config format.signaturefile expect" here,
which handles unsetting after the test. Besides being one line shorter,
it also cleans up when the middle part of the test fails.
You could also use "git -c", but I think setting the actual config in a
file is a more realistic test.
-Peff
prev parent reply other threads:[~2014-05-19 10:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-18 20:22 [PATCH v4] format-patch --signature-file <file> Jeremiah Mahler
2014-05-18 20:22 ` Jeremiah Mahler
2014-05-19 10:48 ` Jeff King [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=20140519104810.GA17492@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=jmmahler@gmail.com \
/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).