Browse Source

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 <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Michael J Gruber 14 years ago committed by Junio C Hamano
parent
commit
e10dfb62ee
  1. 12
      builtin/tag.c

12
builtin/tag.c

@ -29,8 +29,6 @@ struct tag_filter {
struct commit_list *with_commit; struct commit_list *with_commit;
}; };


#define PGP_SIGNATURE "-----BEGIN PGP SIGNATURE-----"

static int show_reference(const char *refname, const unsigned char *sha1, static int show_reference(const char *refname, const unsigned char *sha1,
int flag, void *cb_data) int flag, void *cb_data)
{ {
@ -242,8 +240,7 @@ static void write_tag_body(int fd, const unsigned char *sha1)
{ {
unsigned long size; unsigned long size;
enum object_type type; enum object_type type;
char *buf, *sp, *eob; char *buf, *sp;
size_t len;


buf = read_sha1_file(sha1, &type, &size); buf = read_sha1_file(sha1, &type, &size);
if (!buf) if (!buf)
@ -256,12 +253,7 @@ static void write_tag_body(int fd, const unsigned char *sha1)
return; return;
} }
sp += 2; /* skip the 2 LFs */ sp += 2; /* skip the 2 LFs */
eob = strstr(sp, "\n" PGP_SIGNATURE "\n"); write_or_die(fd, sp, parse_signature(sp, buf + size - sp));
if (eob)
len = eob - sp;
else
len = buf + size - sp;
write_or_die(fd, sp, len);


free(buf); free(buf);
} }

Loading…
Cancel
Save