Skip to content

Commit e10dfb6

Browse files
Michael J Grubergitster
authored andcommitted
tag: factor out sig detection for body edits
Use the factored out code for sig detection when editing existing tag bodies (tag -a -f without -m). Signed-off-by: Michael J Gruber <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ac58c4c commit e10dfb6

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

builtin/tag.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ struct tag_filter {
2929
struct commit_list *with_commit;
3030
};
3131

32-
#define PGP_SIGNATURE "-----BEGIN PGP SIGNATURE-----"
33-
3432
static int show_reference(const char *refname, const unsigned char *sha1,
3533
int flag, void *cb_data)
3634
{
@@ -242,8 +240,7 @@ static void write_tag_body(int fd, const unsigned char *sha1)
242240
{
243241
unsigned long size;
244242
enum object_type type;
245-
char *buf, *sp, *eob;
246-
size_t len;
243+
char *buf, *sp;
247244

248245
buf = read_sha1_file(sha1, &type, &size);
249246
if (!buf)
@@ -256,12 +253,7 @@ static void write_tag_body(int fd, const unsigned char *sha1)
256253
return;
257254
}
258255
sp += 2; /* skip the 2 LFs */
259-
eob = strstr(sp, "\n" PGP_SIGNATURE "\n");
260-
if (eob)
261-
len = eob - sp;
262-
else
263-
len = buf + size - sp;
264-
write_or_die(fd, sp, len);
256+
write_or_die(fd, sp, parse_signature(sp, buf + size - sp));
265257

266258
free(buf);
267259
}

0 commit comments

Comments
 (0)