Skip to content

Commit f766b36

Browse files
committed
Make git_status_config() file scope static to builtin-commit.c
Signed-off-by: Junio C Hamano <[email protected]>
1 parent 23900a9 commit f766b36

File tree

3 files changed

+60
-61
lines changed

3 files changed

+60
-61
lines changed

builtin-commit.c

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,66 @@ static int dry_run_commit(int argc, const char **argv, const char *prefix,
826826
return commitable ? 0 : 1;
827827
}
828828

829+
static int parse_status_slot(const char *var, int offset)
830+
{
831+
if (!strcasecmp(var+offset, "header"))
832+
return WT_STATUS_HEADER;
833+
if (!strcasecmp(var+offset, "updated")
834+
|| !strcasecmp(var+offset, "added"))
835+
return WT_STATUS_UPDATED;
836+
if (!strcasecmp(var+offset, "changed"))
837+
return WT_STATUS_CHANGED;
838+
if (!strcasecmp(var+offset, "untracked"))
839+
return WT_STATUS_UNTRACKED;
840+
if (!strcasecmp(var+offset, "nobranch"))
841+
return WT_STATUS_NOBRANCH;
842+
if (!strcasecmp(var+offset, "unmerged"))
843+
return WT_STATUS_UNMERGED;
844+
die("bad config variable '%s'", var);
845+
}
846+
847+
static int git_status_config(const char *k, const char *v, void *cb)
848+
{
849+
struct wt_status *s = cb;
850+
851+
if (!strcmp(k, "status.submodulesummary")) {
852+
int is_bool;
853+
s->submodule_summary = git_config_bool_or_int(k, v, &is_bool);
854+
if (is_bool && s->submodule_summary)
855+
s->submodule_summary = -1;
856+
return 0;
857+
}
858+
if (!strcmp(k, "status.color") || !strcmp(k, "color.status")) {
859+
s->use_color = git_config_colorbool(k, v, -1);
860+
return 0;
861+
}
862+
if (!prefixcmp(k, "status.color.") || !prefixcmp(k, "color.status.")) {
863+
int slot = parse_status_slot(k, 13);
864+
if (!v)
865+
return config_error_nonbool(k);
866+
color_parse(v, k, s->color_palette[slot]);
867+
return 0;
868+
}
869+
if (!strcmp(k, "status.relativepaths")) {
870+
s->relative_paths = git_config_bool(k, v);
871+
return 0;
872+
}
873+
if (!strcmp(k, "status.showuntrackedfiles")) {
874+
if (!v)
875+
return config_error_nonbool(k);
876+
else if (!strcmp(v, "no"))
877+
s->show_untracked_files = SHOW_NO_UNTRACKED_FILES;
878+
else if (!strcmp(v, "normal"))
879+
s->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
880+
else if (!strcmp(v, "all"))
881+
s->show_untracked_files = SHOW_ALL_UNTRACKED_FILES;
882+
else
883+
return error("Invalid untracked files mode '%s'", v);
884+
return 0;
885+
}
886+
return git_diff_ui_config(k, v, NULL);
887+
}
888+
829889
int cmd_status(int argc, const char **argv, const char *prefix)
830890
{
831891
struct wt_status s;

wt-status.c

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,6 @@ static char default_wt_status_colors[][COLOR_MAXLEN] = {
1919
GIT_COLOR_RED, /* WT_STATUS_UNMERGED */
2020
};
2121

22-
static int parse_status_slot(const char *var, int offset)
23-
{
24-
if (!strcasecmp(var+offset, "header"))
25-
return WT_STATUS_HEADER;
26-
if (!strcasecmp(var+offset, "updated")
27-
|| !strcasecmp(var+offset, "added"))
28-
return WT_STATUS_UPDATED;
29-
if (!strcasecmp(var+offset, "changed"))
30-
return WT_STATUS_CHANGED;
31-
if (!strcasecmp(var+offset, "untracked"))
32-
return WT_STATUS_UNTRACKED;
33-
if (!strcasecmp(var+offset, "nobranch"))
34-
return WT_STATUS_NOBRANCH;
35-
if (!strcasecmp(var+offset, "unmerged"))
36-
return WT_STATUS_UNMERGED;
37-
die("bad config variable '%s'", var);
38-
}
39-
4022
static const char *color(int slot, struct wt_status *s)
4123
{
4224
return s->use_color > 0 ? s->color_palette[slot] : "";
@@ -594,45 +576,3 @@ void wt_status_print(struct wt_status *s)
594576
printf("nothing to commit (working directory clean)\n");
595577
}
596578
}
597-
598-
int git_status_config(const char *k, const char *v, void *cb)
599-
{
600-
struct wt_status *s = cb;
601-
602-
if (!strcmp(k, "status.submodulesummary")) {
603-
int is_bool;
604-
s->submodule_summary = git_config_bool_or_int(k, v, &is_bool);
605-
if (is_bool && s->submodule_summary)
606-
s->submodule_summary = -1;
607-
return 0;
608-
}
609-
if (!strcmp(k, "status.color") || !strcmp(k, "color.status")) {
610-
s->use_color = git_config_colorbool(k, v, -1);
611-
return 0;
612-
}
613-
if (!prefixcmp(k, "status.color.") || !prefixcmp(k, "color.status.")) {
614-
int slot = parse_status_slot(k, 13);
615-
if (!v)
616-
return config_error_nonbool(k);
617-
color_parse(v, k, s->color_palette[slot]);
618-
return 0;
619-
}
620-
if (!strcmp(k, "status.relativepaths")) {
621-
s->relative_paths = git_config_bool(k, v);
622-
return 0;
623-
}
624-
if (!strcmp(k, "status.showuntrackedfiles")) {
625-
if (!v)
626-
return config_error_nonbool(k);
627-
else if (!strcmp(v, "no"))
628-
s->show_untracked_files = SHOW_NO_UNTRACKED_FILES;
629-
else if (!strcmp(v, "normal"))
630-
s->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
631-
else if (!strcmp(v, "all"))
632-
s->show_untracked_files = SHOW_ALL_UNTRACKED_FILES;
633-
else
634-
return error("Invalid untracked files mode '%s'", v);
635-
return 0;
636-
}
637-
return git_diff_ui_config(k, v, NULL);
638-
}

wt-status.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ struct wt_status {
5050
struct string_list change;
5151
};
5252

53-
int git_status_config(const char *var, const char *value, void *cb);
5453
void wt_status_prepare(struct wt_status *s);
5554
void wt_status_print(struct wt_status *s);
5655
void wt_status_collect_changes(struct wt_status *s);

0 commit comments

Comments
 (0)