git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Elijah Newren <newren@gmail.com>
To: Eugen Konkov <kes-kes@yandex.ru>
Cc: Git Mailing List <git@vger.kernel.org>,
	Derrick Stolee <stolee@gmail.com>
Subject: Re: Ambigious messages
Date: Sat, 31 Jul 2021 18:27:07 -0600	[thread overview]
Message-ID: <CABPp-BHkhwKFb74fUMW3nOGrCD6waBPBjp-UY2fRhU6=WUxOow@mail.gmail.com> (raw)
In-Reply-To: <644619140.20210731114616@yandex.ru>

Hi Eugen,

On Sat, Jul 31, 2021 at 2:56 AM Eugen Konkov <kes-kes@yandex.ru> wrote:
>
> $ git checkout 51c7d41b82b5b
> error: Your local changes to the following files would be overwritten by checkout:
>        lib/Mojo/IOLoop/Stream.pm
> Please commit your changes or stash them before you switch branches.
> Aborting

The error seems quite reasonable to me...but can I ask how you got
into this state?

There's two ways I know of:

1) Setting a sparse-checkout to only have certain paths, and then
recreating a file outside the sparsity paths anyway.
2) Trying to adjust your sparse-checkout to have a different set of
paths, then hit Ctrl-C while it is in the middle of running.

Did you do one of these?  If not, what'd you do?  If so, which one?

I've only had confused users come to me when they did the latter; they
apparently assumed Ctrl-C would abort the operation and return to the
previous state, but it does not -- whatever was successfully checked
out before they hit Ctrl-C remains written to the working copy, but
the .git/info/sparse-checkout file is updated last so the system
continues assuming the old checkout.  I wonder if we need to add some
special Ctrl-C handling inside sparse-checkout adjustments or
something.

> $ git checkout lib/Mojo/IOLoop/Stream.pm
> error: pathspec 'lib/Mojo/IOLoop/Stream.pm' did not match any file(s) known to git

This error message is clearly suboptimal and should be improved.
Alternatively, though, we could perhaps change the behavior so that
when in a sparse-checkout and the file(s) that match are SKIP_WORKTREE
but present anyway, we could just remove the file from the working
copy (i.e. make it match the index).

> $ git add lib/Mojo/IOLoop/Stream.pm
> The following pathspecs didn't match any eligible path, but they do match index
> entries outside the current sparse checkout:
> lib/Mojo/IOLoop/Stream.pm
> hint: Disable or modify the sparsity rules if you intend to update such entries.
> hint: Disable this message with "git config advice.updateSparsePath false"

The error message is correct, but this is the case Stolee was talking
about recently where it'd be good to add an override to "git add" to
allow adding it anyway and add information about using that option to
this error message.

> $ git --version
> git version 2.32.0
>
> Here I do not understand how to checkout to different commit
> or how to commit the subject file

I'll give you three different ways you should be able to do it:

1. Since you wanted to just restore the file to the version in the
index (as per your `git checkout lib/Mojo/IOLoop/Stream.pm` command),
you can simply delete the file (`rm lib/Mojo/IOLoop/Stream.pm`) and
everything would be fine.

2. You could change your sparsity paths to include this file so it
doesn't think it should be excluded from the working tree, e.g. `git
sparse-checkout add lib/Mojo/IOLoop` or even `git sparse-checkout add
lib/Mojo/IOLoop/Stream.pm`.  That'd be most useful if you made
important edits to the file or want to continue editing the file and
committing changes in it.

3. You could just disable the sparse-checkout entirely (`git
sparse-checkout disable`).  That'd make it so you don't have to worry
about this path or any other being simultaneously excluded and present
in the working tree.  You should be able to fix things up normally.
And, if you want, when you're done fixing things up, then set up a
sparse-checkout again.


> It would be nice to show hint about how to exlude this file from unindex

Yes, we need to improve some error messages here (and perhaps tweak
some behavior as well).  Thanks for the report.

Elijah

  parent reply	other threads:[~2021-08-01  0:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-31  8:46 Ambigious messages Eugen Konkov
2021-07-31 12:31 ` Ambigious messages (sparse checkout) Philip Oakley
2021-08-01  0:27 ` Elijah Newren [this message]
2021-08-02 13:48   ` Ambigious messages Eugen Konkov

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='CABPp-BHkhwKFb74fUMW3nOGrCD6waBPBjp-UY2fRhU6=WUxOow@mail.gmail.com' \
    --to=newren@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=kes-kes@yandex.ru \
    --cc=stolee@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).