wt-status: move wt_status_get_state() out to wt_status_print()

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Mar 13, 2013 at 18:42 UTC 3b691cccb02e660002a7ff414ad21ddac932dc6c
1 file changed +20 -19
wt-status.c
+20 -19
@@ -1031,32 +1031,30 @@ void wt_status_get_state(struct wt_status_state *state)
1031 }
1032 }
1033
1034 -static void wt_status_print_state(struct wt_status *s)
1034 +static void wt_status_print_state(struct wt_status *s,
1035 + struct wt_status_state *state)
1036 {
1037 const char *state_color = color(WT_STATUS_HEADER, s);
1037 - struct wt_status_state state;
1038 -
1039 - memset(&state, 0, sizeof(state));
1040 - wt_status_get_state(&state);
1041 -
1042 - if (state.merge_in_progress)
1043 - show_merge_in_progress(s, &state, state_color);
1044 - else if (state.am_in_progress)
1045 - show_am_in_progress(s, &state, state_color);
1046 - else if (state.rebase_in_progress || state.rebase_interactive_in_progress)
1047 - show_rebase_in_progress(s, &state, state_color);
1048 - else if (state.cherry_pick_in_progress)
1049 - show_cherry_pick_in_progress(s, &state, state_color);
1050 - if (state.bisect_in_progress)
1051 - show_bisect_in_progress(s, &state, state_color);
1052 - free(state.branch);
1053 - free(state.onto);
1038 + if (state->merge_in_progress)
1039 + show_merge_in_progress(s, state, state_color);
1040 + else if (state->am_in_progress)
1041 + show_am_in_progress(s, state, state_color);
1042 + else if (state->rebase_in_progress || state->rebase_interactive_in_progress)
1043 + show_rebase_in_progress(s, state, state_color);
1044 + else if (state->cherry_pick_in_progress)
1045 + show_cherry_pick_in_progress(s, state, state_color);
1046 + if (state->bisect_in_progress)
1047 + show_bisect_in_progress(s, state, state_color);
1048 }
1049
1050 void wt_status_print(struct wt_status *s)
1051 {
1052 const char *branch_color = color(WT_STATUS_ONBRANCH, s);
1053 const char *branch_status_color = color(WT_STATUS_HEADER, s);
1054 + struct wt_status_state state;
1055 +
1056 + memset(&state, 0, sizeof(state));
1057 + wt_status_get_state(&state);
1058
1059 if (s->branch) {
1060 const char *on_what = _("On branch ");
@@ -1075,7 +1073,10 @@ void wt_status_print(struct wt_status *s)
1073 wt_status_print_tracking(s);
1074 }
1075
1078 - wt_status_print_state(s);
1076 + wt_status_print_state(s, &state);
1077 + free(state.branch);
1078 + free(state.onto);
1079 +
1080 if (s->is_initial) {
1081 status_printf_ln(s, color(WT_STATUS_HEADER, s), "");
1082 status_printf_ln(s, color(WT_STATUS_HEADER, s), _("Initial commit"));