Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> --- wt-status.c | 41 +++++++++++++++++++++++------------------ wt-status.h | 1 + 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/wt-status.c b/wt-status.c index 6cac27b..0d8989f 100644 --- a/wt-status.c +++ b/wt-status.c @@ -1001,40 +1001,45 @@ got_nothing: return NULL; } -static void wt_status_print_state(struct wt_status *s) +void wt_status_get_state(struct wt_status_state *state) { - const char *state_color = color(WT_STATUS_HEADER, s); - struct wt_status_state state; struct stat st; - memset(&state, 0, sizeof(state)); - if (!stat(git_path("MERGE_HEAD"), &st)) { - state.merge_in_progress = 1; + state->merge_in_progress = 1; } else if (!stat(git_path("rebase-apply"), &st)) { if (!stat(git_path("rebase-apply/applying"), &st)) { - state.am_in_progress = 1; + state->am_in_progress = 1; if (!stat(git_path("rebase-apply/patch"), &st) && !st.st_size) - state.am_empty_patch = 1; + state->am_empty_patch = 1; } else { - state.rebase_in_progress = 1; - state.branch = read_and_strip_branch("rebase-apply/head-name"); - state.onto = read_and_strip_branch("rebase-apply/onto"); + state->rebase_in_progress = 1; + state->branch = read_and_strip_branch("rebase-apply/head-name"); + state->onto = read_and_strip_branch("rebase-apply/onto"); } } else if (!stat(git_path("rebase-merge"), &st)) { if (!stat(git_path("rebase-merge/interactive"), &st)) - state.rebase_interactive_in_progress = 1; + state->rebase_interactive_in_progress = 1; else - state.rebase_in_progress = 1; - state.branch = read_and_strip_branch("rebase-merge/head-name"); - state.onto = read_and_strip_branch("rebase-merge/onto"); + state->rebase_in_progress = 1; + state->branch = read_and_strip_branch("rebase-merge/head-name"); + state->onto = read_and_strip_branch("rebase-merge/onto"); } else if (!stat(git_path("CHERRY_PICK_HEAD"), &st)) { - state.cherry_pick_in_progress = 1; + state->cherry_pick_in_progress = 1; } if (!stat(git_path("BISECT_LOG"), &st)) { - state.bisect_in_progress = 1; - state.branch = read_and_strip_branch("BISECT_START"); + state->bisect_in_progress = 1; + state->branch = read_and_strip_branch("BISECT_START"); } +} + +static void wt_status_print_state(struct wt_status *s) +{ + const char *state_color = color(WT_STATUS_HEADER, s); + struct wt_status_state state; + + memset(&state, 0, sizeof(state)); + wt_status_get_state(&state); if (state.merge_in_progress) show_merge_in_progress(s, &state, state_color); diff --git a/wt-status.h b/wt-status.h index b8c3512..5ddcbf6 100644 --- a/wt-status.h +++ b/wt-status.h @@ -86,6 +86,7 @@ struct wt_status_state { void wt_status_prepare(struct wt_status *s); void wt_status_print(struct wt_status *s); void wt_status_collect(struct wt_status *s); +void wt_status_get_state(struct wt_status_state *state); void wt_shortstatus_print(struct wt_status *s); void wt_porcelain_print(struct wt_status *s); -- 1.8.1.2.536.gf441e6d -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html