* Sets commit_id to the commit hash where the mail was generated from. * Returns 0 on success, -1 on failure. */
| 1330 | * Returns 0 on success, -1 on failure. |
| 1331 | */ |
| 1332 | static int get_mail_commit_oid(struct object_id *commit_id, const char *mail) |
| 1333 | { |
| 1334 | struct strbuf sb = STRBUF_INIT; |
| 1335 | FILE *fp = xfopen(mail, "r"); |
| 1336 | const char *x; |
| 1337 | int ret = 0; |
| 1338 | |
| 1339 | if (strbuf_getline_lf(&sb, fp) || |
| 1340 | !skip_prefix(sb.buf, "From ", &x) || |
| 1341 | get_oid_hex(x, commit_id) < 0) |
| 1342 | ret = -1; |
| 1343 | |
| 1344 | strbuf_release(&sb); |
| 1345 | fclose(fp); |
| 1346 | return ret; |
| 1347 | } |
| 1348 | |
| 1349 | /** |
| 1350 | * Sets state->msg, state->author_name, state->author_email, state->author_date |
no test coverage detected