| 1158 | }; |
| 1159 | |
| 1160 | int 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 | |
| 1191 | int parse_signed_commit(const struct commit *commit, |
| 1192 | struct strbuf *payload, struct strbuf *signature, |
no test coverage detected