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>
Michael J Gruber committed
Nov 10, 2010 at 12:17 UTC
e10dfb62ee21a3970ccfe44f30f97fcd6457bb78
1 file changed
+2
-10
builtin/tag.c
+2
-10
@@ -29,8 +29,6 @@ struct tag_filter {
29
struct commit_list *with_commit;
30
};
31
32
-#define PGP_SIGNATURE "-----BEGIN PGP SIGNATURE-----"
33
-
32
static int show_reference(const char *refname, const unsigned char *sha1,
33
int flag, void *cb_data)
34
{
@@ -242,8 +240,7 @@ static void write_tag_body(int fd, const unsigned char *sha1)
240
{
241
unsigned long size;
242
enum object_type type;
245
- char *buf, *sp, *eob;
246
- size_t len;
243
+ char *buf, *sp;
244
245
buf = read_sha1_file(sha1, &type, &size);
246
if (!buf)
@@ -256,12 +253,7 @@ static void write_tag_body(int fd, const unsigned char *sha1)
253
return;
254
}
255
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));
257
258
free(buf);
259
}