| 1821 | } |
| 1822 | |
| 1823 | void wt_status_get_state(struct repository *r, |
| 1824 | struct wt_status_state *state, |
| 1825 | int get_detached_from) |
| 1826 | { |
| 1827 | struct stat st; |
| 1828 | struct object_id oid; |
| 1829 | enum replay_action action; |
| 1830 | struct worktree *wt = get_current_worktree(r); |
| 1831 | |
| 1832 | if (!stat(git_path_merge_head(r), &st)) { |
| 1833 | wt_status_check_rebase(wt, state); |
| 1834 | state->merge_in_progress = 1; |
| 1835 | } else if (wt_status_check_rebase(wt, state)) { |
| 1836 | ; /* all set */ |
| 1837 | } else if (refs_ref_exists(get_main_ref_store(r), "CHERRY_PICK_HEAD") && |
| 1838 | !repo_get_oid(r, "CHERRY_PICK_HEAD", &oid)) { |
| 1839 | state->cherry_pick_in_progress = 1; |
| 1840 | oidcpy(&state->cherry_pick_head_oid, &oid); |
| 1841 | } |
| 1842 | wt_status_check_bisect(wt, state); |
| 1843 | if (refs_ref_exists(get_main_ref_store(r), "REVERT_HEAD") && |
| 1844 | !repo_get_oid(r, "REVERT_HEAD", &oid)) { |
| 1845 | state->revert_in_progress = 1; |
| 1846 | oidcpy(&state->revert_head_oid, &oid); |
| 1847 | } |
| 1848 | if (!sequencer_get_last_command(r, &action)) { |
| 1849 | if (action == REPLAY_PICK && !state->cherry_pick_in_progress) { |
| 1850 | state->cherry_pick_in_progress = 1; |
| 1851 | oidcpy(&state->cherry_pick_head_oid, null_oid(r->hash_algo)); |
| 1852 | } else if (action == REPLAY_REVERT && !state->revert_in_progress) { |
| 1853 | state->revert_in_progress = 1; |
| 1854 | oidcpy(&state->revert_head_oid, null_oid(r->hash_algo)); |
| 1855 | } |
| 1856 | } |
| 1857 | if (get_detached_from) |
| 1858 | wt_status_get_detached_from(r, state); |
| 1859 | wt_status_check_sparse_checkout(r, state); |
| 1860 | |
| 1861 | free_worktree(wt); |
| 1862 | } |
| 1863 | |
| 1864 | static void wt_longstatus_print_state(struct wt_status *s) |
| 1865 | { |
no test coverage detected