git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Shawn O. Pearce" <spearce@spearce.org>
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org, Andy Parkins <andyparkins@gmail.com>
Subject: [PATCH 1/2] Suggest use of 'git add' when 'nothing to commit' gets shown.
Date: Thu, 14 Dec 2006 19:13:50 -0500	[thread overview]
Message-ID: <20061215001350.GA26755@spearce.org> (raw)

If a user modifies files and runs 'git commit' (without the very
useful -a option) and they have not yet updated the index they
are probably coming from another SCM-like tool which would perform
the same as 'git commit -a' in this case.  Showing the user their
current status and a final line of "nothing to commit" is not very
reassuring, as the user might believe that Git did not recognize
their files were modified.

Instead we can suggest as part of the 'nothing to commit' message
that the user invoke 'git add' to add files to their next commit.

Suggested by Andy Parkins in his Git 'niggles' list
(<200612132237.10051.andyparkins@gmail.com>).

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 git-commit.sh |    2 +-
 wt-status.c   |    7 ++++---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/git-commit.sh b/git-commit.sh
index 05828bb..fb69e11 100755
--- a/git-commit.sh
+++ b/git-commit.sh
@@ -515,7 +515,7 @@ then
 	current="$(git-rev-parse --verify HEAD)"
 else
 	if [ -z "$(git-ls-files)" ]; then
-		echo >&2 Nothing to commit
+		echo >&2 "Nothing to commit (use \"git add\" include for commit)"
 		exit 1
 	fi
 	PARENTS=""
diff --git a/wt-status.c b/wt-status.c
index 6e9414d..f9ed54f 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -163,7 +163,7 @@ static void wt_status_print_changed_cb(struct diff_queue_struct *q,
 	int i;
 	if (q->nr)
 		wt_status_print_header("Changed but not updated",
-				"use git-add on files to include for commit");
+				"use \"git add\" on files to include for commit");
 	for (i = 0; i < q->nr; i++)
 		wt_status_print_filepair(WT_STATUS_CHANGED, q->queue[i]);
 	if (q->nr)
@@ -250,7 +250,7 @@ static void wt_status_print_untracked(const struct wt_status *s)
 		}
 		if (!shown_header) {
 			wt_status_print_header("Untracked files",
-				"use \"git add\" to add to commit");
+				"use \"git add\" on files to include for commit");
 			shown_header = 1;
 		}
 		color_printf(color(WT_STATUS_HEADER), "#\t");
@@ -292,7 +292,8 @@ void wt_status_print(struct wt_status *s)
 	if (s->verbose && !s->is_initial)
 		wt_status_print_verbose(s);
 	if (!s->commitable)
-		printf("%s\n", s->amend ? "# No changes" : "nothing to commit");
+		printf("%s (use \"git add\" include for commit)\n",
+			s->amend ? "# No changes" : "Nothing to commit");
 }
 
 int git_status_config(const char *k, const char *v)
-- 
1.4.4.2.g72f5

             reply	other threads:[~2006-12-15  0:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-15  0:13 Shawn O. Pearce [this message]
2006-12-15  9:11 ` [PATCH 1/2] Suggest use of 'git add' when 'nothing to commit' gets shown Andreas Ericsson
2006-12-15 15:06   ` Shawn Pearce

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=20061215001350.GA26755@spearce.org \
    --to=spearce@spearce.org \
    --cc=andyparkins@gmail.com \
    --cc=git@vger.kernel.org \
    --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).