Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
trailer: display a trailer without its trailing newline
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>
  • Loading branch information
Christian Couder authored and Junio C Hamano committed Nov 10, 2014
1 parent 2887103 commit d52adf1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions trailer.c
Expand Up @@ -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);
Expand Down

0 comments on commit d52adf1

Please sign in to comment.