diff options
author | Jeff King <peff@peff.net> | 2017-08-15 12:23:21 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-08-15 20:13:58 +0200 |
commit | 56c493ed1b9c067813fb95ff7cd4f69c7c1d2e36 (patch) | |
tree | 44ddaa8efbb61e13812138830ea2137de66304ea /t/t7513-interpret-trailers.sh | |
parent | trailer: put process_trailers() options into a struct (diff) | |
download | git-56c493ed1b9c067813fb95ff7cd4f69c7c1d2e36.tar.xz git-56c493ed1b9c067813fb95ff7cd4f69c7c1d2e36.zip |
interpret-trailers: add an option to show only the trailers
In theory it's easy for any reader who wants to parse
trailers to do so. But there are a lot of subtle corner
cases around what counts as a trailer, when the trailer
block begins and ends, etc. Since interpret-trailers already
has our parsing logic, let's let callers ask it to just
output the trailers.
They still have to parse the "key: value" lines, but at
least they can ignore all of the other corner cases.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t7513-interpret-trailers.sh')
-rwxr-xr-x | t/t7513-interpret-trailers.sh | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/t/t7513-interpret-trailers.sh b/t/t7513-interpret-trailers.sh index 0c6f91c433..90d30037b7 100755 --- a/t/t7513-interpret-trailers.sh +++ b/t/t7513-interpret-trailers.sh @@ -1275,4 +1275,43 @@ test_expect_success 'with cut line' ' test_cmp expected actual ' +test_expect_success 'only trailers' ' + git config trailer.sign.command "echo config-value" && + cat >expected <<-\EOF && + existing: existing-value + sign: config-value + added: added-value + EOF + git interpret-trailers \ + --trailer added:added-value \ + --only-trailers >actual <<-\EOF && + my subject + + my body + + existing: existing-value + EOF + test_cmp expected actual +' + +test_expect_success 'only-trailers omits non-trailer in middle of block' ' + git config trailer.sign.command "echo config-value" && + cat >expected <<-\EOF && + Signed-off-by: nobody <nobody@nowhere> + Signed-off-by: somebody <somebody@somewhere> + sign: config-value + EOF + git interpret-trailers --only-trailers >actual <<-\EOF && + subject + + it is important that the trailers below are signed-off-by + so that they meet the "25% trailers Git knows about" heuristic + + Signed-off-by: nobody <nobody@nowhere> + this is not a trailer + Signed-off-by: somebody <somebody@somewhere> + EOF + test_cmp expected actual +' + test_done |