git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martin Kletzander <mk@linux.com>
To: git@vger.kernel.org
Subject: Possible tiny bug in reset's error message
Date: Mon, 13 Mar 2017 15:55:08 +0100	[thread overview]
Message-ID: <20170313145508.GA3222@wheatley> (raw)

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

                 reply	other threads:[~2017-03-13 14:55 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20170313145508.GA3222@wheatley \
    --to=mk@linux.com \
    --cc=git@vger.kernel.org \
    /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).