Skip to content

Commit

Permalink
wt-status: split wt_status_state parsing function out
Browse files Browse the repository at this point in the history
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Nguyễn Thái Ngọc Duy authored and Junio C Hamano committed Mar 17, 2013
1 parent 8b87cfd commit b9691db
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
41 changes: 23 additions & 18 deletions wt-status.c
Original file line number Diff line number Diff line change
Expand Up @@ -999,40 +999,45 @@ static char *read_and_strip_branch(const char *path)
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);
Expand Down
1 change: 1 addition & 0 deletions wt-status.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b9691db

Please sign in to comment.