Skip to content

Commit d4c4f18

Browse files
committed
Merge branch 'cc/interpret-trailers'
Small fixes to a new experimental command already in 'master'. * cc/interpret-trailers: trailer: display a trailer without its trailing newline trailer: ignore comment lines inside the trailers
2 parents e69b1ce + d52adf1 commit d4c4f18

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

trailer.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -582,8 +582,12 @@ static int parse_trailer(struct strbuf *tok, struct strbuf *val, const char *tra
582582
strbuf_addch(&seps, '=');
583583
len = strcspn(trailer, seps.buf);
584584
strbuf_release(&seps);
585-
if (len == 0)
586-
return error(_("empty trailer token in trailer '%s'"), trailer);
585+
if (len == 0) {
586+
int l = strlen(trailer);
587+
while (l > 0 && isspace(trailer[l - 1]))
588+
l--;
589+
return error(_("empty trailer token in trailer '%.*s'"), l, trailer);
590+
}
587591
if (len < strlen(trailer)) {
588592
strbuf_add(tok, trailer, len);
589593
strbuf_trim(tok);
@@ -803,8 +807,10 @@ static int process_input_file(struct strbuf **lines,
803807

804808
/* Parse trailer lines */
805809
for (i = trailer_start; i < patch_start; i++) {
806-
struct trailer_item *new = create_trailer_item(lines[i]->buf);
807-
add_trailer_item(in_tok_first, in_tok_last, new);
810+
if (lines[i]->buf[0] != comment_line_char) {
811+
struct trailer_item *new = create_trailer_item(lines[i]->buf);
812+
add_trailer_item(in_tok_first, in_tok_last, new);
813+
}
808814
}
809815

810816
return patch_start;

0 commit comments

Comments
 (0)