How about doing this?
-- >8 --
git-status: squelch "use 'git add file...'" message when unneeded
Add a field in wt_status to record if there are any uncached
changes, and use it to decide when there is no point to add the
"use 'git add'" message.
---
diff --git a/wt-status.c b/wt-status.c
index db42738..1037c94 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -15,7 +15,7 @@ static char wt_status_colors[][COLOR_MAXLEN] = {
"\033[31m", /* WT_STATUS_CHANGED: red */
"\033[31m", /* WT_STATUS_UNTRACKED: red */
};
-static const char* use_add_msg = "use \"git add file1 file2\" to include for commit";
+static const char* use_add_msg = "use \"git add file...\" to include for commit";
static int parse_status_slot(const char *var, int offset)
{
@@ -162,13 +162,17 @@ static void wt_status_print_changed_cb(struct diff_queue_struct *q,
struct diff_options *options,
void *data)
{
+ struct wt_status *s = (struct wt_status *)data;
int i;
- if (q->nr)
- wt_status_print_header("Changed but not added", use_add_msg);
+
+ s->modified = q->nr;
+ if (!q->nr)
+ return;
+
+ wt_status_print_header("Changed but not added", use_add_msg);
for (i = 0; i < q->nr; i++)
wt_status_print_filepair(WT_STATUS_CHANGED, q->queue[i]);
- if (q->nr)
- wt_status_print_trailer();
+ wt_status_print_trailer();
}
void wt_status_print_initial(struct wt_status *s)
@@ -291,10 +295,14 @@ void wt_status_print(struct wt_status *s)
if (s->verbose && !s->is_initial)
wt_status_print_verbose(s);
- if (!s->commitable)
- printf("%s (%s)\n",
- s->amend ? "# No changes" : "nothing to commit",
- use_add_msg);
+ if (!s->commitable) {
+ const char *msg =
+ s->amend ? "# No changes" : "nothing to commit";
+ if (s->modified)
+ printf("%s (%s)\n", msg, use_add_msg);
+ else
+ printf("%s\n", msg);
+ }
}
int git_status_config(const char *k, const char *v)
diff --git a/wt-status.h b/wt-status.h
index 0a5a5b7..72df1b3 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -13,6 +13,7 @@ struct wt_status {
char *branch;
const char *reference;
int commitable;
+ int modified;
int verbose;
int amend;
int untracked;
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html