Skip to content

Commit 3c1eb9c

Browse files
j-rJunio C Hamano
authored andcommitted
Improve cached content header of status output
This tries to be more to the point while also including a pointer on how to unstage changes from the index. Since this header is printed in two different code paths and the name of the reference commit is needed for the unstage part, provide a new printing function. Signed-off-by: Jürgen Rühle <j-r@online.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 98bf8a4 commit 3c1eb9c

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

wt-status.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,18 @@ void wt_status_prepare(struct wt_status *s)
5353
s->workdir_clean = 1;
5454
}
5555

56+
static void wt_status_print_cached_header(const char *reference)
57+
{
58+
const char *c = color(WT_STATUS_HEADER);
59+
color_printf_ln(c, "# Cached changes to be committed:");
60+
if (reference) {
61+
color_printf_ln(c, "# (use \"git reset %s <file>...\" and \"git rm --cached <file>...\" to unstage)", reference);
62+
} else {
63+
color_printf_ln(c, "# (use \"git rm --cached <file>...\" to unstage)");
64+
}
65+
color_printf_ln(c, "#");
66+
}
67+
5668
static void wt_status_print_header(const char *main, const char *sub)
5769
{
5870
const char *c = color(WT_STATUS_HEADER);
@@ -147,8 +159,7 @@ static void wt_status_print_updated_cb(struct diff_queue_struct *q,
147159
if (q->queue[i]->status == 'U')
148160
continue;
149161
if (!shown_header) {
150-
wt_status_print_header("Added but not yet committed",
151-
"will commit");
162+
wt_status_print_cached_header(s->reference);
152163
s->commitable = 1;
153164
shown_header = 1;
154165
}
@@ -182,8 +193,7 @@ void wt_status_print_initial(struct wt_status *s)
182193
read_cache();
183194
if (active_nr) {
184195
s->commitable = 1;
185-
wt_status_print_header("Added but not yet committed",
186-
"will commit");
196+
wt_status_print_cached_header(NULL);
187197
}
188198
for (i = 0; i < active_nr; i++) {
189199
color_printf(color(WT_STATUS_HEADER), "#\t");

0 commit comments

Comments
 (0)