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 <gitster@pobox.com>
Junio C Hamano committed
Apr 10, 2010 at 00:19 UTC
1b908b6fb48f4f8009804c097b14106df548247c
1 file changed
+14
-8
wt-status.c
+14
-8
@@ -97,13 +97,15 @@ static void wt_status_print_dirty_header(struct wt_status *s,
97
color_fprintf_ln(s->fp, c, "#");
98
}
99
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)
103
{
104
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);
106
if (!advice_status_hints)
107
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);
109
color_fprintf_ln(s->fp, c, "#");
110
}
111
@@ -541,7 +543,10 @@ static void wt_status_print_submodule_summary(struct wt_status *s, int uncommitt
543
run_command(&sm_summary);
544
}
545
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)
550
{
551
int i;
552
struct strbuf buf = STRBUF_INIT;
@@ -549,10 +554,11 @@ static void wt_status_print_untracked(struct wt_status *s)
554
if (!s->untracked.nr)
555
return;
556
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++) {
560
struct string_list_item *it;
555
- it = &(s->untracked.items[i]);
561
+ it = &(l->items[i]);
562
color_fprintf(s->fp, color(WT_STATUS_HEADER, s), "#\t");
563
color_fprintf_ln(s->fp, color(WT_STATUS_UNTRACKED, s), "%s",
564
quote_path(it->string, strlen(it->string),
@@ -641,7 +647,7 @@ void wt_status_print(struct wt_status *s)
647
wt_status_print_submodule_summary(s, 1); /* unstaged */
648
}
649
if (s->show_untracked_files)
644
- wt_status_print_untracked(s);
650
+ wt_status_print_other(s, &s->untracked, "Untracked", "add");
651
else if (s->commitable)
652
fprintf(s->fp, "# Untracked files not listed (use -u option to show untracked files)\n");
653