diff options
author | Christian Couder <chriscool@tuxfamily.org> | 2014-11-09 10:23:40 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-11-10 09:43:59 -0800 |
commit | d52adf1f328162a9513940913ced044d24c0212f (patch) | |
tree | 81f229ea345aa9194af1a33b206b053984e15514 /trailer.c | |
parent | 2887103b35b3b40025ca5060713dfb1e1c8c3b20 (diff) | |
download | git-d52adf1f328162a9513940913ced044d24c0212f.tar.gz |
trailer: display a trailer without its trailing newlinecc/interpret-trailers
Trailers passed to the parse_trailer() function often have
a trailing newline. When erroring out, we should display
the invalid trailer properly, that means without any
trailing newline.
Helped-by: Junio C Hamano <gitster@pobox.com>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'trailer.c')
-rw-r--r-- | trailer.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -583,8 +583,12 @@ static int parse_trailer(struct strbuf *tok, struct strbuf *val, const char *tra strbuf_addch(&seps, '='); len = strcspn(trailer, seps.buf); strbuf_release(&seps); - if (len == 0) - return error(_("empty trailer token in trailer '%s'"), trailer); + if (len == 0) { + int l = strlen(trailer); + while (l > 0 && isspace(trailer[l - 1])) + l--; + return error(_("empty trailer token in trailer '%.*s'"), l, trailer); + } if (len < strlen(trailer)) { strbuf_add(tok, trailer, len); strbuf_trim(tok); |