| 1495 | } |
| 1496 | |
| 1497 | static int parse_head(struct repository *r, struct commit **head) |
| 1498 | { |
| 1499 | struct commit *current_head; |
| 1500 | struct object_id oid; |
| 1501 | |
| 1502 | if (repo_get_oid(r, "HEAD", &oid)) { |
| 1503 | current_head = NULL; |
| 1504 | } else { |
| 1505 | current_head = lookup_commit_reference(r, &oid); |
| 1506 | if (!current_head) |
| 1507 | return error(_("could not parse HEAD")); |
| 1508 | if (!oideq(&oid, ¤t_head->object.oid)) { |
| 1509 | warning(_("HEAD %s is not a commit!"), |
| 1510 | oid_to_hex(&oid)); |
| 1511 | } |
| 1512 | if (repo_parse_commit(r, current_head)) |
| 1513 | return error(_("could not parse HEAD commit")); |
| 1514 | } |
| 1515 | *head = current_head; |
| 1516 | |
| 1517 | return 0; |
| 1518 | } |
| 1519 | |
| 1520 | /* |
| 1521 | * Try to commit without forking 'git commit'. In some cases we need |
no test coverage detected