From: "Štěpán Němec" <stepnem@gmail.com>
To: Jeenu V <jeenuv@gmail.com>
Cc: knittl <knittl89@googlemail.com>, git@vger.kernel.org
Subject: [PATCH] Hint at "checkout -p" in the "reset --patch <type>" error message
Date: Tue, 23 Nov 2010 15:20:58 +0100 [thread overview]
Message-ID: <87mxp086k5.fsf_-_@gmail.com> (raw)
In-Reply-To: <AANLkTimEOULR8_PAs5iPu7z+n4DQPSyDKYg8RghZxosz@mail.gmail.com> (Jeenu V.'s message of "Tue, 23 Nov 2010 18:30:39 +0530")
The --patch option to git-reset is not compatible with the type
specifiers (--hard et al.), but some users try that first when what they
really want is "checkout -p" (cf.
<http://permalink.gmane.org/gmane.comp.version-control.git/161955>).
Mention "git checkout -p" in the error message to point users in the
right direction.
Signed-off-by: Štěpán Němec <stepnem@gmail.com>
---
Jeenu V <jeenuv@gmail.com> writes:
> On Tue, Nov 23, 2010 at 4:28 PM, knittl <knittl89@googlemail.com> wrote:
>> `git reset` seldomly affects the working tree, unless using `--hard`,
>> `--merge` or `--keep`, and those switches are potentially dangerous if
>> you are not aware of the implications to your worktree and index.
>>
>> without options reset undoes a previous add, i.e. remove changes from
>> the index, but not the working tree.
>>
>> git reset manpage mentions git-checkout:
>
> Agreed. What I'm saying is most manuals/guides out there tips user to
> use 'git reset --hard' to discard changes in the working directory and
> restore the pristine copy of files. 'reset' then becomes synonymous to
> discard, and it kind of is but for a different reason. Because other
> commands offer -p for selective operations, one might try to discard
> selectively, and end up using 'git reset -p --hard', which obviously
> isn't going to work.
>
> Knowing the users intention in such cases, I was suggesting the error
> message could hint the right command (just like git commit hints user
> to use git-add when one does 'git commit' with a dirty working tree).
>
> But that's just me.
Well, maybe something like the patch below wouldn't hurt?
builtin/reset.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/builtin/reset.c b/builtin/reset.c
index 0037be4..fc530d2 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -309,7 +309,8 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
if (patch_mode) {
if (reset_type != NONE)
- die("--patch is incompatible with --{hard,mixed,soft}");
+ die("--patch is incompatible with --{hard,mixed,soft}\n"
+ "(use \"git checkout -p\" to selectively discard changes in working directory)");
return interactive_reset(rev, argv + i, prefix);
}
--
1.7.3.rc2.221.gbf93f.dirty
next prev parent reply other threads:[~2010-11-23 14:22 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-23 9:11 Git reset -p on working tree Jeenu V
2010-11-23 9:20 ` knittl
2010-11-23 10:26 ` Jeenu V
2010-11-23 10:32 ` Jeenu V
2010-11-23 10:58 ` knittl
2010-11-23 13:00 ` Jeenu V
2010-11-23 14:20 ` Štěpán Němec [this message]
2010-11-23 14:59 ` [PATCH] Hint at "checkout -p" in the "reset --patch <type>" error message Jeff King
2010-11-23 15:23 ` Štěpán Němec
2010-11-25 8:55 ` Michael J Gruber
2010-11-25 10:56 ` Jakub Narebski
2010-11-25 13:10 ` Michael J Gruber
2010-11-25 15:56 ` Matthieu Moy
2010-11-25 16:14 ` Jeff King
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=87mxp086k5.fsf_-_@gmail.com \
--to=stepnem@gmail.com \
--cc=git@vger.kernel.org \
--cc=jeenuv@gmail.com \
--cc=knittl89@googlemail.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).