Skip to content

Commit 1b908b6

Browse files
committed
wt-status: rename and restructure status-print-untracked
I will be reusing this to show ignored stuff in the next patch. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6cb3f6b commit 1b908b6

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

wt-status.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,15 @@ static void wt_status_print_dirty_header(struct wt_status *s,
9797
color_fprintf_ln(s->fp, c, "#");
9898
}
9999

100-
static void wt_status_print_untracked_header(struct wt_status *s)
100+
static void wt_status_print_other_header(struct wt_status *s,
101+
const char *what,
102+
const char *how)
101103
{
102104
const char *c = color(WT_STATUS_HEADER, s);
103-
color_fprintf_ln(s->fp, c, "# Untracked files:");
105+
color_fprintf_ln(s->fp, c, "# %s files:", what);
104106
if (!advice_status_hints)
105107
return;
106-
color_fprintf_ln(s->fp, c, "# (use \"git add <file>...\" to include in what will be committed)");
108+
color_fprintf_ln(s->fp, c, "# (use \"git %s <file>...\" to include in what will be committed)", how);
107109
color_fprintf_ln(s->fp, c, "#");
108110
}
109111

@@ -541,18 +543,22 @@ static void wt_status_print_submodule_summary(struct wt_status *s, int uncommitt
541543
run_command(&sm_summary);
542544
}
543545

544-
static void wt_status_print_untracked(struct wt_status *s)
546+
static void wt_status_print_other(struct wt_status *s,
547+
struct string_list *l,
548+
const char *what,
549+
const char *how)
545550
{
546551
int i;
547552
struct strbuf buf = STRBUF_INIT;
548553

549554
if (!s->untracked.nr)
550555
return;
551556

552-
wt_status_print_untracked_header(s);
553-
for (i = 0; i < s->untracked.nr; i++) {
557+
wt_status_print_other_header(s, what, how);
558+
559+
for (i = 0; i < l->nr; i++) {
554560
struct string_list_item *it;
555-
it = &(s->untracked.items[i]);
561+
it = &(l->items[i]);
556562
color_fprintf(s->fp, color(WT_STATUS_HEADER, s), "#\t");
557563
color_fprintf_ln(s->fp, color(WT_STATUS_UNTRACKED, s), "%s",
558564
quote_path(it->string, strlen(it->string),
@@ -641,7 +647,7 @@ void wt_status_print(struct wt_status *s)
641647
wt_status_print_submodule_summary(s, 1); /* unstaged */
642648
}
643649
if (s->show_untracked_files)
644-
wt_status_print_untracked(s);
650+
wt_status_print_other(s, &s->untracked, "Untracked", "add");
645651
else if (s->commitable)
646652
fprintf(s->fp, "# Untracked files not listed (use -u option to show untracked files)\n");
647653

0 commit comments

Comments
 (0)