MCPcopy Create free account
hub / github.com/git/git / cmd__delete_gpgsig

Function cmd__delete_gpgsig

t/helper/test-delete-gpgsig.c:6–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4
5
6int cmd__delete_gpgsig(int argc, const char **argv)
7{
8 struct strbuf buf = STRBUF_INIT;
9 const char *pattern = "gpgsig";
10 const char *bufptr, *tail, *eol;
11 int deleting = 0;
12 size_t plen;
13
14 if (argc >= 2) {
15 pattern = argv[1];
16 argv++;
17 argc--;
18 }
19
20 plen = strlen(pattern);
21 strbuf_read(&buf, 0, 0);
22
23 if (!strcmp(pattern, "trailer")) {
24 size_t payload_size = parse_signed_buffer(buf.buf, buf.len);
25 fwrite(buf.buf, 1, payload_size, stdout);
26 goto out;
27 }
28
29 bufptr = buf.buf;
30 tail = bufptr + buf.len;
31
32 while (bufptr < tail) {
33 /* Find the end of the line */
34 eol = memchr(bufptr, '\n', tail - bufptr);
35 if (!eol)
36 eol = tail;
37
38 /* Drop continuation lines */
39 if (deleting && (bufptr < eol) && (bufptr[0] == ' ')) {
40 bufptr = eol + 1;
41 continue;
42 }
43 deleting = 0;
44
45 /* Does the line match the prefix? */
46 if (((bufptr + plen) < eol) &&
47 !memcmp(bufptr, pattern, plen) &&
48 (bufptr[plen] == ' ')) {
49 deleting = 1;
50 bufptr = eol + 1;
51 continue;
52 }
53
54 /* Print all other lines */
55 fwrite(bufptr, 1, (eol - bufptr) + 1, stdout);
56 bufptr = eol + 1;
57 }
58
59out:
60 fflush(stdout);
61 strbuf_release(&buf);
62 return 0;
63}

Callers

nothing calls this directly

Calls 3

strbuf_readFunction · 0.85
parse_signed_bufferFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected