status: cleanup API to wt_status_print

Refactor the API between builtin/commit.c and wt-status.[ch].

Hide the details of the various wt_*status_print() routines inside
wt-status.c behind a single (new) wt_status_print() routine.
Eliminate the switch statements from builtin/commit.c.
Allow details of new status formats to be isolated within wt-status.c

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jeff Hostetler
2016-08-05 18:00:27 -04:00
committed by Junio C Hamano
parent 957a0fe2e5
commit be7e795efe
3 changed files with 43 additions and 49 deletions

View File

@ -1447,7 +1447,7 @@ static void wt_longstatus_print_state(struct wt_status *s,
show_bisect_in_progress(s, state, state_color);
}
void wt_longstatus_print(struct wt_status *s)
static void wt_longstatus_print(struct wt_status *s)
{
const char *branch_color = color(WT_STATUS_ONBRANCH, s);
const char *branch_status_color = color(WT_STATUS_HEADER, s);
@ -1714,7 +1714,7 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
fputc(s->null_termination ? '\0' : '\n', s->fp);
}
void wt_shortstatus_print(struct wt_status *s)
static void wt_shortstatus_print(struct wt_status *s)
{
int i;
@ -1746,7 +1746,7 @@ void wt_shortstatus_print(struct wt_status *s)
}
}
void wt_porcelain_print(struct wt_status *s)
static void wt_porcelain_print(struct wt_status *s)
{
s->use_color = 0;
s->relative_paths = 0;
@ -1754,3 +1754,22 @@ void wt_porcelain_print(struct wt_status *s)
s->no_gettext = 1;
wt_shortstatus_print(s);
}
void wt_status_print(struct wt_status *s)
{
switch (s->status_format) {
case STATUS_FORMAT_SHORT:
wt_shortstatus_print(s);
break;
case STATUS_FORMAT_PORCELAIN:
wt_porcelain_print(s);
break;
case STATUS_FORMAT_UNSPECIFIED:
die("BUG: finalize_deferred_config() should have been called");
break;
case STATUS_FORMAT_NONE:
case STATUS_FORMAT_LONG:
wt_longstatus_print(s);
break;
}
}