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 <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson committed
Feb 11, 2021 at 02:08 UTC
88bce0e24c8f777fce1f726b4553bd32286bba04
1 file changed
+3
-4
ref-filter.c
+3
-4
@@ -1221,6 +1221,8 @@ static void find_subpos(const char *buf,
1221
const char *end = buf + strlen(buf);
1222
const char *sigstart;
1223
1224
+ /* parse signature first; we might not even have a subject line */
1225
+ parse_signature(buf, end - buf, &payload, &signature);
1226
1227
/* skip past header until we hit empty line */
1228
while (*buf && *buf != '\n') {
@@ -1232,9 +1234,6 @@ static void find_subpos(const char *buf,
1234
/* skip any empty lines */
1235
while (*buf == '\n')
1236
buf++;
1235
-
1236
- /* parse signature first; we might not even have a subject line */
1237
- parse_signature(buf, end - buf, &payload, &signature);
1237
*sig = strbuf_detach(&signature, siglen);
1238
sigstart = buf + parse_signed_buffer(buf, strlen(buf));
1239
@@ -1330,7 +1329,7 @@ static void grab_sub_body_contents(struct atom_value *val, int deref, void *buf)
1329
v->s = xmemdupz(sigpos, siglen);
1330
else if (atom->u.contents.option == C_LINES) {
1331
struct strbuf s = STRBUF_INIT;
1333
- const char *contents_end = bodylen + bodypos - siglen;
1332
+ const char *contents_end = bodypos + nonsiglen;
1333
1334
/* Size is the length of the message after removing the signature */
1335
append_lines(&s, subpos, contents_end - subpos, atom->u.contents.nlines);