| 2566 | } |
| 2567 | |
| 2568 | static int read_and_refresh_cache(struct repository *r, |
| 2569 | struct replay_opts *opts) |
| 2570 | { |
| 2571 | struct lock_file index_lock = LOCK_INIT; |
| 2572 | int index_fd = repo_hold_locked_index(r, &index_lock, 0); |
| 2573 | if (repo_read_index(r) < 0) { |
| 2574 | rollback_lock_file(&index_lock); |
| 2575 | return error(_("git %s: failed to read the index"), |
| 2576 | action_name(opts)); |
| 2577 | } |
| 2578 | refresh_index(r->index, REFRESH_QUIET|REFRESH_UNMERGED, NULL, NULL, NULL); |
| 2579 | |
| 2580 | if (index_fd >= 0) { |
| 2581 | if (write_locked_index(r->index, &index_lock, |
| 2582 | COMMIT_LOCK | SKIP_IF_UNCHANGED)) { |
| 2583 | return error(_("git %s: failed to refresh the index"), |
| 2584 | action_name(opts)); |
| 2585 | } |
| 2586 | } |
| 2587 | |
| 2588 | /* |
| 2589 | * If we are resolving merges in any way other than "ort", then |
| 2590 | * expand the sparse index. |
| 2591 | */ |
| 2592 | if (opts->strategy && strcmp(opts->strategy, "ort")) |
| 2593 | ensure_full_index(r->index); |
| 2594 | return 0; |
| 2595 | } |
| 2596 | |
| 2597 | void todo_list_release(struct todo_list *todo_list) |
| 2598 | { |
no test coverage detected