git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Hint at "checkout -p" in the "reset --patch <type>" error message

From
Štěpán Němec <stepnem@gmail.com>
Date
Nov 23, 2010, 15:23 UTC
Message-ID
<87ipzo83o9.fsf@gmail.com>
In-Reply-To
<20101123145921.GB3145@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 28 quoted lines
> On Tue, Nov 23, 2010 at 03:20:58PM +0100, Štěpán Němec wrote:
>
>> 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);
>>  	}
>
> Should this actually print something different for --hard versus --mixed
> versus --soft?
>
> For --soft, "-p" simply makes no sense as you are not changing the index
> or the working directory.
>
> For --mixed, shouldn't we support "-p" already, as that is the default
> mode?
>
> For --hard, suggesting "checkout -p" does make sense.
>
> Also, what about "--merge" and "--keep" modes?

All good questions, most of which occured to me, too. What I was going to do based on the outcome of (the discussion of) this patch was at least fix the currently out-of-date "--{hard,mixed,soft}", as the error is signalled with the newer options (--keep and --merge) as well. I'm not sure I could cope with anything much more complicated than that, esp. if it involved adding some new reset functionality. :-)

What about this instead:
diff --git a/builtin/reset.c b/builtin/reset.c
index 0037be4..7779302 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -308,8 +308,11 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
 	hashcpy(sha1, commit->object.sha1);
 
 	if (patch_mode) {
-		if (reset_type != NONE)
-			die("--patch is incompatible with --{hard,mixed,soft}");
+		if (reset_type == HARD)
+			die("--patch is incompatible with --hard\n"
+			    "(use \"git checkout -p\" to selectively discard changes in working directory)");
+		if (reset_type != MIXED)
+			die("--patch is incompatible with --{hard,soft,keep,merge}");
 		return interactive_reset(rev, argv + i, prefix);
 	}
 

Thanks,

  Štěpán
Previous: Jeff KingNext: Michael J Gruber
Message 9 of 14 in “Git reset -p on working tree”
  1. Jeenu VNov 23, 2010
  2. knittlNov 23, 2010
  3. Jeenu VNov 23, 2010
  4. Jeenu VNov 23, 2010
  5. knittlNov 23, 2010
  6. Jeenu VNov 23, 2010
  7. Hint at "checkout -p" in the "reset --patch <type>" error messageŠtěpán Němec, Nov 23, 2010
  8. Jeff KingNov 23, 2010
  9. Štěpán NěmecNov 23, 2010
  10. Michael J GruberNov 25, 2010
  11. Jakub NarebskiNov 25, 2010
  12. Michael J GruberNov 25, 2010
  13. Matthieu MoyNov 25, 2010
  14. Jeff KingNov 25, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.