Skip to content

Commit

Permalink
wt-status: rename and restructure status-print-untracked
Browse files Browse the repository at this point in the history
I will be reusing this to show ignored stuff in the next patch.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed Apr 10, 2010
1 parent 6cb3f6b commit 1b908b6
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions wt-status.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,15 @@ static void wt_status_print_dirty_header(struct wt_status *s,
color_fprintf_ln(s->fp, c, "#");
}

static void wt_status_print_untracked_header(struct wt_status *s)
static void wt_status_print_other_header(struct wt_status *s,
const char *what,
const char *how)
{
const char *c = color(WT_STATUS_HEADER, s);
color_fprintf_ln(s->fp, c, "# Untracked files:");
color_fprintf_ln(s->fp, c, "# %s files:", what);
if (!advice_status_hints)
return;
color_fprintf_ln(s->fp, c, "# (use \"git add <file>...\" to include in what will be committed)");
color_fprintf_ln(s->fp, c, "# (use \"git %s <file>...\" to include in what will be committed)", how);
color_fprintf_ln(s->fp, c, "#");
}

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

static void wt_status_print_untracked(struct wt_status *s)
static void wt_status_print_other(struct wt_status *s,
struct string_list *l,
const char *what,
const char *how)
{
int i;
struct strbuf buf = STRBUF_INIT;

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

wt_status_print_untracked_header(s);
for (i = 0; i < s->untracked.nr; i++) {
wt_status_print_other_header(s, what, how);

for (i = 0; i < l->nr; i++) {
struct string_list_item *it;
it = &(s->untracked.items[i]);
it = &(l->items[i]);
color_fprintf(s->fp, color(WT_STATUS_HEADER, s), "#\t");
color_fprintf_ln(s->fp, color(WT_STATUS_UNTRACKED, s), "%s",
quote_path(it->string, strlen(it->string),
Expand Down Expand Up @@ -641,7 +647,7 @@ void wt_status_print(struct wt_status *s)
wt_status_print_submodule_summary(s, 1); /* unstaged */
}
if (s->show_untracked_files)
wt_status_print_untracked(s);
wt_status_print_other(s, &s->untracked, "Untracked", "add");
else if (s->commitable)
fprintf(s->fp, "# Untracked files not listed (use -u option to show untracked files)\n");

Expand Down

0 comments on commit 1b908b6

Please sign in to comment.