Skip to content

Commit 88bce0e

Browse files
bk2204gitster
authored andcommitted
ref-filter: hoist signature parsing
When we parse a signature in the ref-filter code, we continually increment the buffer pointer. Hoist the signature parsing above the blank line delimiting headers and body so we can find the signature when using a header to sign the buffer. Signed-off-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 937032e commit 88bce0e

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

ref-filter.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,6 +1221,8 @@ static void find_subpos(const char *buf,
12211221
const char *end = buf + strlen(buf);
12221222
const char *sigstart;
12231223

1224+
/* parse signature first; we might not even have a subject line */
1225+
parse_signature(buf, end - buf, &payload, &signature);
12241226

12251227
/* skip past header until we hit empty line */
12261228
while (*buf && *buf != '\n') {
@@ -1232,9 +1234,6 @@ static void find_subpos(const char *buf,
12321234
/* skip any empty lines */
12331235
while (*buf == '\n')
12341236
buf++;
1235-
1236-
/* parse signature first; we might not even have a subject line */
1237-
parse_signature(buf, end - buf, &payload, &signature);
12381237
*sig = strbuf_detach(&signature, siglen);
12391238
sigstart = buf + parse_signed_buffer(buf, strlen(buf));
12401239

@@ -1330,7 +1329,7 @@ static void grab_sub_body_contents(struct atom_value *val, int deref, void *buf)
13301329
v->s = xmemdupz(sigpos, siglen);
13311330
else if (atom->u.contents.option == C_LINES) {
13321331
struct strbuf s = STRBUF_INIT;
1333-
const char *contents_end = bodylen + bodypos - siglen;
1332+
const char *contents_end = bodypos + nonsiglen;
13341333

13351334
/* Size is the length of the message after removing the signature */
13361335
append_lines(&s, subpos, contents_end - subpos, atom->u.contents.nlines);

0 commit comments

Comments
 (0)