Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/helper/test-delete-gpgsig.c # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / helper / test-delete-gpgsig.c` 63 lines ยท 1218 bytes Raw Blame History 1 #include "test-tool.h" 2 #include "gpg-interface.h" 3 #include "strbuf.h" 4 5 6 int 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 59 out: 60 fflush(stdout); 61 strbuf_release(&buf); 62 return 0; 63 }