wt-status: split wt_status_state parsing function out
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
b9691db4f90164b3de2c2ea7e82ea545f2056f52
2 files changed
+24
-18
wt-status.c
+23
-18
@@ -999,40 +999,45 @@ got_nothing:
999
return NULL;
1000
}
1001
1002
-static void wt_status_print_state(struct wt_status *s)
1002
+void wt_status_get_state(struct wt_status_state *state)
1003
{
1004
- const char *state_color = color(WT_STATUS_HEADER, s);
1005
- struct wt_status_state state;
1004
struct stat st;
1005
1008
- memset(&state, 0, sizeof(state));
1009
-
1006
if (!stat(git_path("MERGE_HEAD"), &st)) {
1011
- state.merge_in_progress = 1;
1007
+ state->merge_in_progress = 1;
1008
} else if (!stat(git_path("rebase-apply"), &st)) {
1009
if (!stat(git_path("rebase-apply/applying"), &st)) {
1014
- state.am_in_progress = 1;
1010
+ state->am_in_progress = 1;
1011
if (!stat(git_path("rebase-apply/patch"), &st) && !st.st_size)
1016
- state.am_empty_patch = 1;
1012
+ state->am_empty_patch = 1;
1013
} else {
1018
- state.rebase_in_progress = 1;
1019
- state.branch = read_and_strip_branch("rebase-apply/head-name");
1020
- state.onto = read_and_strip_branch("rebase-apply/onto");
1014
+ state->rebase_in_progress = 1;
1015
+ state->branch = read_and_strip_branch("rebase-apply/head-name");
1016
+ state->onto = read_and_strip_branch("rebase-apply/onto");
1017
}
1018
} else if (!stat(git_path("rebase-merge"), &st)) {
1019
if (!stat(git_path("rebase-merge/interactive"), &st))
1024
- state.rebase_interactive_in_progress = 1;
1020
+ state->rebase_interactive_in_progress = 1;
1021
else
1026
- state.rebase_in_progress = 1;
1027
- state.branch = read_and_strip_branch("rebase-merge/head-name");
1028
- state.onto = read_and_strip_branch("rebase-merge/onto");
1022
+ state->rebase_in_progress = 1;
1023
+ state->branch = read_and_strip_branch("rebase-merge/head-name");
1024
+ state->onto = read_and_strip_branch("rebase-merge/onto");
1025
} else if (!stat(git_path("CHERRY_PICK_HEAD"), &st)) {
1030
- state.cherry_pick_in_progress = 1;
1026
+ state->cherry_pick_in_progress = 1;
1027
}
1028
if (!stat(git_path("BISECT_LOG"), &st)) {
1033
- state.bisect_in_progress = 1;
1034
- state.branch = read_and_strip_branch("BISECT_START");
1029
+ state->bisect_in_progress = 1;
1030
+ state->branch = read_and_strip_branch("BISECT_START");
1031
}
1032
+}
1033
+
1034
+static void wt_status_print_state(struct wt_status *s)
1035
+{
1036
+ 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);
wt-status.h
+1
@@ -86,6 +86,7 @@ struct wt_status_state {
86
void wt_status_prepare(struct wt_status *s);
87
void wt_status_print(struct wt_status *s);
88
void wt_status_collect(struct wt_status *s);
89
+void wt_status_get_state(struct wt_status_state *state);
90
91
void wt_shortstatus_print(struct wt_status *s);
92
void wt_porcelain_print(struct wt_status *s);