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

Possible tiny bug in reset's error message

From
MKMartin Kletzander <mk@linux.com>
Date
Mar 13, 2017, 14:55 UTC
Message-ID
<20170313145508.GA3222@wheatley>
Hi,

when I was trying to learn some details about various types of resets, I found out that the default reset type is --mixed, but not specifying it is not the same as specifying it. That's mostly because there are some checks for reset_type before setting it to default value. Since one of the checks seem deliberate, I'm rather asking here before sending wrong patch.

The "bug" I am talking about is:
  $ g reset -p --mixed
  fatal: --patch is incompatible with --{hard,mixed,soft}
  $ g reset -p
  No changes.
Despite the fact that `git help reset` says:
  If <mode> is omitted, defaults to "--mixed".

The reason why I'm rather asking is the part of the code that handles the warning message for:

  $ git reset --mixed -- path
  warning: --mixed with paths is deprecated; use 'git reset -- <paths>'
  instead.
Specifically:
	/* git reset tree [--] paths... can be used to
	 * load chosen paths from the tree into the index without
	 * affecting the working tree nor HEAD. */
	if (pathspec.nr) {
		if (reset_type == MIXED)
			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]));
	}
See how NONE and MIXED are both purposefully checked?

So my question is, should reset_type be set to MIXED if it was not specified on the command-line before all these checks? If not, what's the reason for that?

Have a nice day, Martin

Message 1 of 1 in “Possible tiny bug in reset's error message”
  1. Martin KletzanderMar 13, 2017

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.