git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
	"Jonathan Nieder" <jrnieder@gmail.com>,
	"Ralf Ebert" <info@ralfebert.de>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [PATCH v2] reset: Better warning message on git reset --mixed <paths>
Date: Sun, 15 Aug 2010 08:43:20 +0000	[thread overview]
Message-ID: <1281861800-424-1-git-send-email-avarab@gmail.com> (raw)
In-Reply-To: <20100814210505.GA2372@burratino>

When you call "git reset --mixed <paths>" git will complain that using
mixed with paths is deprecated:

    warning: --mixed option is deprecated with paths.

That doesn't tell the user why it's deprecated, or what he should use
instead. Expand on the warning and tell the user to just omit --mixed:

    warning: --mixed with paths is deprecated; use 'git reset -- <paths>' instead

The exact wording of the warning was suggested by Jonathan Nieder.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---

On Sat, Aug 14, 2010 at 21:05, Jonathan Nieder <jrnieder@gmail.com> wrote:
> Maybe:
>
>  warning: --mixed with paths is deprecated; use 'git reset -- <paths>' instead

That's better, thanks. Here's an amended version, and with tests this
time.

 builtin/reset.c           |    2 +-
 t/t7112-reset-messages.sh |   33 +++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 1 deletions(-)
 create mode 100755 t/t7112-reset-messages.sh

diff --git a/builtin/reset.c b/builtin/reset.c
index 1283068..0037be4 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -318,7 +318,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
 	 * affecting the working tree nor HEAD. */
 	if (i < argc) {
 		if (reset_type == MIXED)
-			warning("--mixed option is deprecated with paths.");
+			warning("--mixed with paths is deprecated; use 'git reset -- <paths>' instead.");
 		else if (reset_type != NONE)
 			die("Cannot do %s reset with paths.",
 					reset_type_names[reset_type]);
diff --git a/t/t7112-reset-messages.sh b/t/t7112-reset-messages.sh
new file mode 100755
index 0000000..6f2669b
--- /dev/null
+++ b/t/t7112-reset-messages.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+#
+# Copyright (c) 2010 Ævar Arnfjörð Bjarmason
+#
+
+test_description='git reset warning and error messages'
+
+. ./test-lib.sh
+
+test_expect_success 'setup {err,out}-expect' "
+	cat >err-expect <<EOF &&
+warning: --mixed with paths is deprecated; use 'git reset -- <paths>' instead.
+EOF
+	cat >out-expect <<EOF
+Unstaged changes after reset:
+M	hlagh
+EOF
+"
+
+test_expect_success 'git reset --mixed <paths> warning' '
+	# Not test_commit() due to "ambiguous argument [..] both revision
+	# and filename"
+	echo stuff >hlagh &&
+	git add hlagh &&
+	git commit -m"adding stuff" hlagh &&
+	echo more stuff >hlagh &&
+	git add hlagh &&
+	test_must_fail git reset --mixed hlagh >out 2>err &&
+	test_cmp err-expect err &&
+	test_cmp out-expect out
+'
+
+test_done
-- 
1.7.2.1.339.gfad93

  parent reply	other threads:[~2010-08-15 15:34 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-14 19:34 [PATCH] reset: Better warning message on git reset --mixed <paths> Ævar Arnfjörð Bjarmason
2010-08-14 21:05 ` Jonathan Nieder
2010-08-15  1:47   ` Junio C Hamano
2010-08-15  2:43     ` Miles Bader
2010-08-15  8:38       ` Ævar Arnfjörð Bjarmason
2010-08-15 18:36         ` Junio C Hamano
2010-08-15 19:49           ` Jonathan Nieder
2010-08-15 22:18             ` Junio C Hamano
2010-08-15 20:51           ` Ævar Arnfjörð Bjarmason
2010-08-15 22:22             ` Junio C Hamano
2010-08-16  0:59             ` Miles Bader
2010-08-16  1:13               ` Ævar Arnfjörð Bjarmason
2010-08-15 21:05           ` Ralf Ebert
2010-08-16  0:12             ` Jonathan Nieder
2010-08-15 13:02       ` David Fries
2010-08-15  8:43   ` Ævar Arnfjörð Bjarmason [this message]
2010-08-16  3:39     ` [PATCH v2] " Junio C Hamano
2010-08-16  4:23       ` Ævar Arnfjörð Bjarmason

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=1281861800-424-1-git-send-email-avarab@gmail.com \
    --to=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=info@ralfebert.de \
    --cc=jrnieder@gmail.com \
    /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).