git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Stefan Beller <sbeller@google.com>
To: mana vortex <manavortex@gmail.com>
Cc: git <git@vger.kernel.org>
Subject: Re: [bug-ish] [convenience] fatal: only [12] (reference)s? expected, [12] given
Date: Wed, 30 May 2018 11:11:10 -0700	[thread overview]
Message-ID: <CAGZ79kb6S0NT7YVH6JBV3W+=ikeBJtdbrTK5y_q9hEaGPzpeeQ@mail.gmail.com> (raw)
In-Reply-To: <1B7D3974-AA1C-42B5-A7F5-C5A36B28C34F@gmail.com>

On Wed, May 30, 2018 at 1:12 AM, mana vortex <manavortex@gmail.com> wrote:
> Hello git folks,
> I’m writing about something that annoys me since forever: The reference
> handling is not consistent between commands. For example, I do
>
> git checkout origin master

  $ git checkout origin master
  error: pathspec 'master' did not match any file(s) known to git.

(I am running a recent build of the next branch,
which version do you run?)

If I do
  git checkout or<TAB>
it auto-completes to
  git checkout origin/
which I can then type master after and it works with origin/master

> but I do
>
> git reset —hard origin/master

That worked for me, and the whitespaced version fails as:
  $ git reset --hard origin master
  fatal: Cannot do hard reset with paths.

I do not understand the problem, yet, as for these two commands
you'd want to give <remote>/<branch> with the slash in between.

> I always get it wrong the first time.

What exactly? The confusion with slash or whitespace?

> Is there a convenience option that circumvents the error?

I think understanding the Git model would help with that:

The only commands that need a whitespace between origin and
master I can think of are push and fetch. These two commands
are commands that use the network to directly talk to the specified
remote and the second argument "master" is just a short form of a
refspec, typed out long it would be "refs/heads/master:refs/heads/master"
which specifies the branch (with full prefix) once on the sending side
and once on the receiving side, separated by colon.

And for these commands we actually talk to the remote.
For all other commands we use the locally cached version of the
branch that we think the remote has, so the "origin" is just a prefix
in the namespace of branches, indicating that all branches under
"origin/" are "remote tracking branches", i.e. these local cached branches.

> If one argument is given, but two are expected, split the argument at the
> first / and retry - throw error if that isn’t valid
> If two arguments are given, but one is expected, concat the arguments with a
> /.
>
> Is that possible already, and if not, would you care to implement it?

I think that would make for hilarious error messages in corner cases;
I am not sure if we want to water down the difference of a remote + refspec
and a local remote tracking branch, such that it is harder to understand?

Thanks,
Stefan

      reply	other threads:[~2018-05-30 18:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-30  8:12 [bug-ish] [convenience] fatal: only [12] (reference)s? expected, [12] given mana vortex
2018-05-30 18:11 ` Stefan Beller [this message]

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAGZ79kb6S0NT7YVH6JBV3W+=ikeBJtdbrTK5y_q9hEaGPzpeeQ@mail.gmail.com' \
    --to=sbeller@google.com \
    --cc=git@vger.kernel.org \
    --cc=manavortex@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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).