git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Juergen Ruehle <j.ruehle@bmiag.de>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <junkio@cox.net>, "Jürgen Rühle" <j-r@online.de>
Subject: [PATCH 3/4] Improve "nothing to commit" part of status output
Date: Tue,  2 Jan 2007 20:26:22 +0100	[thread overview]
Message-ID: <11677659941419-git-send-email-j.ruehle@bmiag.de> (raw)
In-Reply-To: <1167765983316-git-send-email-j.ruehle@bmiag.de>

From: =?iso-8859-1?q?J=FCrgen_R=FChle?= <j-r@online.de>

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>
---
 wt-status.c |   20 +++++++++++++++-----
 wt-status.h |    1 +
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/wt-status.c b/wt-status.c
index 98ca135..302f7ee 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -51,6 +51,8 @@ void wt_status_prepare(struct wt_status *s)
 	s->verbose = 0;
 	s->commitable = 0;
 	s->untracked = 0;
+
+	s->workdir_clean = 1;
 }
 
 static void wt_status_print_cached_header(const char *reference)
@@ -173,9 +175,12 @@ static void wt_status_print_changed_cb(struct diff_queue_struct *q,
                         struct diff_options *options,
                         void *data)
 {
+	struct wt_status *s = data;
 	int i;
-	if (q->nr)
+	if (q->nr) {
+		s->workdir_clean = 0;
 		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)
@@ -225,7 +230,7 @@ static void wt_status_print_changed(struct wt_status *s)
 	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;
 	const char *x;
@@ -260,6 +265,7 @@ static void wt_status_print_untracked(const struct wt_status *s)
 				continue;
 		}
 		if (!shown_header) {
+			s->workdir_clean = 0;
 			wt_status_print_header("Untracked files", use_add_msg);
 			shown_header = 1;
 		}
@@ -302,9 +308,13 @@ 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->amend)
+			printf("# No changes\n");
+		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)
diff --git a/wt-status.h b/wt-status.h
index 0a5a5b7..892a86c 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -16,6 +16,7 @@ struct wt_status {
 	int verbose;
 	int amend;
 	int untracked;
+	int workdir_clean;
 };
 
 int git_status_config(const char *var, const char *value);
-- 
1.5.0.rc0.g31e2

  parent reply	other threads:[~2007-01-02 19:27 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-02 19:26 [PATCH/RFC] Assorted small changes to runstatus Juergen Ruehle
2007-01-02 19:26 ` [PATCH 1/4] Clarify syntax and role of git-add in status output Juergen Ruehle
2007-01-02 19:26 ` [PATCH 2/4] Improve cached content header of " Juergen Ruehle
2007-01-05 10:54   ` Andy Whitcroft
2007-01-05 11:22     ` Junio C Hamano
2007-01-05 13:14       ` Andy Whitcroft
2007-01-05 17:14         ` Juergen Ruehle
2007-01-05 18:42           ` Junio C Hamano
2007-01-08 13:28             ` Andy Whitcroft
2007-01-08 14:27               ` Juergen Ruehle
2007-01-02 19:26 ` Juergen Ruehle [this message]
2007-01-02 19:26 ` [PATCH 4/4] Support --amend on initial commit in " Juergen Ruehle
2007-01-03  2:51 ` [PATCH/RFC] Assorted small changes to runstatus Junio C Hamano
2007-01-03  5:34   ` Juergen Ruehle
2007-01-07 19:18 ` [PATCH] Remove unnecessary git-rm --cached reference from status output Juergen Ruehle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11677659941419-git-send-email-j.ruehle@bmiag.de \
    --to=j.ruehle@bmiag.de \
    --cc=git@vger.kernel.org \
    --cc=j-r@online.de \
    --cc=junkio@cox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).