Skip to content

Commit f68f2dd

Browse files
peffgitster
authored andcommitted
gpg-interface: extract gpg line matching helper
Let's separate the actual line-by-line parsing of signatures from the notion of "is this a gpg signature line". That will make it easier to do more refactoring of this loop in future patches. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Ben Toews <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 17ef3a4 commit f68f2dd

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

gpg-interface.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,16 @@ void print_signature_buffer(const struct signature_check *sigc, unsigned flags)
101101
fputs(output, stderr);
102102
}
103103

104+
static int is_gpg_start(const char *line)
105+
{
106+
return starts_with(line, PGP_SIGNATURE) ||
107+
starts_with(line, PGP_MESSAGE);
108+
}
109+
104110
size_t parse_signature(const char *buf, size_t size)
105111
{
106112
size_t len = 0;
107-
while (len < size && !starts_with(buf + len, PGP_SIGNATURE) &&
108-
!starts_with(buf + len, PGP_MESSAGE)) {
113+
while (len < size && !is_gpg_start(buf + len)) {
109114
const char *eol = memchr(buf + len, '\n', size - len);
110115
len += eol ? eol - (buf + len) + 1 : size - len;
111116
}

0 commit comments

Comments
 (0)