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>
Jürgen Rühle committed
Jan 2, 2007 at 20:26 UTC
3c1eb9cb2d57769f770ddc36fd6b49706608ebb7
1 file changed
+14
-4
wt-status.c
+14
-4
@@ -53,6 +53,18 @@ void wt_status_prepare(struct wt_status *s)
53
s->workdir_clean = 1;
54
}
55
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
+
68
static void wt_status_print_header(const char *main, const char *sub)
69
{
70
const char *c = color(WT_STATUS_HEADER);
@@ -147,8 +159,7 @@ static void wt_status_print_updated_cb(struct diff_queue_struct *q,
159
if (q->queue[i]->status == 'U')
160
continue;
161
if (!shown_header) {
150
- wt_status_print_header("Added but not yet committed",
151
- "will commit");
162
+ wt_status_print_cached_header(s->reference);
163
s->commitable = 1;
164
shown_header = 1;
165
}
@@ -182,8 +193,7 @@ void wt_status_print_initial(struct wt_status *s)
193
read_cache();
194
if (active_nr) {
195
s->commitable = 1;
185
- wt_status_print_header("Added but not yet committed",
186
- "will commit");
196
+ wt_status_print_cached_header(NULL);
197
}
198
for (i = 0; i < active_nr; i++) {
199
color_printf(color(WT_STATUS_HEADER), "#\t");