Improve "nothing to commit" part of status output
Previously git-status in a clean working directory would advice the user to use git add. This isn't very helpful when there is nothing to add in the working directory, therefore note a clean working directory while displaying the other sections and print the appropriate message for each case. Signed-off-by: Jürgen Rühle <j-r@online.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
parent
e54eef9e1f
commit
6e458bf63f
24
wt-status.c
24
wt-status.c
@ -51,6 +51,8 @@ void wt_status_prepare(struct wt_status *s)
|
|||||||
s->verbose = 0;
|
s->verbose = 0;
|
||||||
s->commitable = 0;
|
s->commitable = 0;
|
||||||
s->untracked = 0;
|
s->untracked = 0;
|
||||||
|
|
||||||
|
s->workdir_clean = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wt_status_print_header(const char *main, const char *sub)
|
static void wt_status_print_header(const char *main, const char *sub)
|
||||||
@ -162,9 +164,12 @@ static void wt_status_print_changed_cb(struct diff_queue_struct *q,
|
|||||||
struct diff_options *options,
|
struct diff_options *options,
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
|
struct wt_status *s = data;
|
||||||
int i;
|
int i;
|
||||||
if (q->nr)
|
if (q->nr) {
|
||||||
|
s->workdir_clean = 0;
|
||||||
wt_status_print_header("Changed but not added", use_add_msg);
|
wt_status_print_header("Changed but not added", use_add_msg);
|
||||||
|
}
|
||||||
for (i = 0; i < q->nr; i++)
|
for (i = 0; i < q->nr; i++)
|
||||||
wt_status_print_filepair(WT_STATUS_CHANGED, q->queue[i]);
|
wt_status_print_filepair(WT_STATUS_CHANGED, q->queue[i]);
|
||||||
if (q->nr)
|
if (q->nr)
|
||||||
@ -215,7 +220,7 @@ static void wt_status_print_changed(struct wt_status *s)
|
|||||||
run_diff_files(&rev, 0);
|
run_diff_files(&rev, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wt_status_print_untracked(const struct wt_status *s)
|
static void wt_status_print_untracked(struct wt_status *s)
|
||||||
{
|
{
|
||||||
struct dir_struct dir;
|
struct dir_struct dir;
|
||||||
const char *x;
|
const char *x;
|
||||||
@ -250,6 +255,7 @@ static void wt_status_print_untracked(const struct wt_status *s)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!shown_header) {
|
if (!shown_header) {
|
||||||
|
s->workdir_clean = 0;
|
||||||
wt_status_print_header("Untracked files", use_add_msg);
|
wt_status_print_header("Untracked files", use_add_msg);
|
||||||
shown_header = 1;
|
shown_header = 1;
|
||||||
}
|
}
|
||||||
@ -291,10 +297,16 @@ void wt_status_print(struct wt_status *s)
|
|||||||
|
|
||||||
if (s->verbose && !s->is_initial)
|
if (s->verbose && !s->is_initial)
|
||||||
wt_status_print_verbose(s);
|
wt_status_print_verbose(s);
|
||||||
if (!s->commitable)
|
if (!s->commitable) {
|
||||||
printf("%s (%s)\n",
|
if (s->amend)
|
||||||
s->amend ? "# No changes" : "nothing to commit",
|
printf("# No changes\n");
|
||||||
use_add_msg);
|
else if (s->workdir_clean)
|
||||||
|
printf(s->is_initial
|
||||||
|
? "nothing to commit\n"
|
||||||
|
: "nothing to commit (working directory matches HEAD)\n");
|
||||||
|
else
|
||||||
|
printf("no changes added to commit (use \"git add\" and/or \"git commit [-a|-i|-o]\")\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int git_status_config(const char *k, const char *v)
|
int git_status_config(const char *k, const char *v)
|
||||||
|
@ -16,6 +16,7 @@ struct wt_status {
|
|||||||
int verbose;
|
int verbose;
|
||||||
int amend;
|
int amend;
|
||||||
int untracked;
|
int untracked;
|
||||||
|
int workdir_clean;
|
||||||
};
|
};
|
||||||
|
|
||||||
int git_status_config(const char *var, const char *value);
|
int git_status_config(const char *var, const char *value);
|
||||||
|
Loading…
Reference in New Issue
Block a user