MCPcopy Index your code
hub / github.com/git/git / add_header_signature

Function add_header_signature

commit.c:1160–1189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1158};
1159
1160int add_header_signature(struct strbuf *buf, struct strbuf *sig, const struct git_hash_algo *algo)
1161{
1162 int inspos, copypos;
1163 const char *eoh;
1164 const char *gpg_sig_header = gpg_sig_headers[hash_algo_by_ptr(algo)];
1165 int gpg_sig_header_len = strlen(gpg_sig_header);
1166
1167 /* find the end of the header */
1168 eoh = strstr(buf->buf, "\n\n");
1169 if (!eoh)
1170 inspos = buf->len;
1171 else
1172 inspos = eoh - buf->buf + 1;
1173
1174 for (copypos = 0; sig->buf[copypos]; ) {
1175 const char *bol = sig->buf + copypos;
1176 const char *eol = strchrnul(bol, '\n');
1177 int len = (eol - bol) + !!*eol;
1178
1179 if (!copypos) {
1180 strbuf_insert(buf, inspos, gpg_sig_header, gpg_sig_header_len);
1181 inspos += gpg_sig_header_len;
1182 }
1183 strbuf_insertstr(buf, inspos++, " ");
1184 strbuf_insert(buf, inspos, bol, len);
1185 inspos += len;
1186 copypos += len;
1187 }
1188 return 0;
1189}
1190
1191int parse_signed_commit(const struct commit *commit,
1192 struct strbuf *payload, struct strbuf *signature,

Callers 4

convert_tag_objectFunction · 0.85
commit_tree_extendedFunction · 0.85
do_signFunction · 0.85

Calls 3

hash_algo_by_ptrFunction · 0.85
strbuf_insertFunction · 0.85
strbuf_insertstrFunction · 0.85

Tested by

no test coverage detected