| 3451 | } |
| 3452 | |
| 3453 | static int rollback_is_safe(void) |
| 3454 | { |
| 3455 | struct strbuf sb = STRBUF_INIT; |
| 3456 | struct object_id expected_head, actual_head; |
| 3457 | |
| 3458 | if (strbuf_read_file(&sb, git_path_abort_safety_file(), 0) >= 0) { |
| 3459 | strbuf_trim(&sb); |
| 3460 | if (get_oid_hex(sb.buf, &expected_head)) { |
| 3461 | strbuf_release(&sb); |
| 3462 | die(_("could not parse %s"), git_path_abort_safety_file()); |
| 3463 | } |
| 3464 | strbuf_release(&sb); |
| 3465 | } |
| 3466 | else if (errno == ENOENT) |
| 3467 | oidclr(&expected_head, the_repository->hash_algo); |
| 3468 | else |
| 3469 | die_errno(_("could not read '%s'"), git_path_abort_safety_file()); |
| 3470 | |
| 3471 | if (repo_get_oid(the_repository, "HEAD", &actual_head)) |
| 3472 | oidclr(&actual_head, the_repository->hash_algo); |
| 3473 | |
| 3474 | return oideq(&actual_head, &expected_head); |
| 3475 | } |
| 3476 | |
| 3477 | static int reset_merge(const struct object_id *oid) |
| 3478 | { |
no test coverage detected