From: Elijah Newren <newren@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Jeff King <peff@peff.net>,
Fedor Biryukov <fedor.birjukov@gmail.com>,
Bagas Sanjaya <bagasdotme@gmail.com>,
Git Mailing List <git@vger.kernel.org>
Subject: Re: Aborting 'rebase main feat' removes unversioned files
Date: Tue, 7 Sep 2021 17:41:02 -0700 [thread overview]
Message-ID: <CABPp-BEvSFWN+sGA_0SSqH3sYKtHWs5YpOJSoCGQ_=e6rpfpyg@mail.gmail.com> (raw)
In-Reply-To: <xmqqr1e2ejs9.fsf@gitster.g>
On Sun, Sep 5, 2021 at 3:31 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> Elijah Newren <newren@gmail.com> writes:
>
> > unpack_trees. In fact, it traces back to (and before)
> > fcc387db9b ("read-tree -m -u: do not overwrite or remove untracked
> > working tree files.", 2006-05-17)
> > which has additional commentary over at
> > https://lore.kernel.org/git/7v8xp1jc9h.fsf_-_@assigned-by-dhcp.cox.net/.
> > It appears that before this time, git happily nuked untracked files
> > and considered them expendable, in basically all cases. However, this
> > patch continued considering them as expendable whenever opts->reset
> > was true.
>
> Thanks for digging. Yes, the 'reset' bit was treated as the license
> to kill untracked working tree files and directories that get in the
> way in order to carry out the unpack_trees operation.
>
> > So, then...should we preserve untracked (and non-ignored) files in all
> > these cases? This rebase case seems clear, but others might be less
> > clear....
>
> In short, the guiding principle ought to be that "checkout --force"
> and anything that is given "force" as a stronger override should be
> allowed to do whatever minimally necessary to match the end result
> in the working tree to what the command wants to show in the absense
> of these untracked paths. And without being forced, untracked and
> unignored paths are precious and should cause commands to fail, if
> they need to be touched for the commands to complete what they are
> asked to do [*].
>
> "reset --hard HEAD" is an oddball.
>
> Naïvely, because it is often used as the way to tell Git to "no
> matter what, match the working tree to HEAD", even though it does
> not have an explicit "--force" on the command line, it feels that it
> also should be allowed to do whatever necessary to the working tree
> files. And historically, that is what we wanted to implement. If
> we suddenly made it "safer", I am sure a lot of existing things will
> break.
>
> But unfortunately, "--hard" means a bit more than that in the
> context of "reset", in that we want to reset in a way that is
> different from "--mixed" (reset the index only without touching the
> working tree) and "--soft" (do not touch the index or the working
> tree), more specifically, with "--hard", we want to reset both the
> index and the working tree to match the given committish (often
> "HEAD"). From that point of view, "reset --hard" that tries to
> preserve untracked and unignored paths, and "reset --force --hard"
> that does whatever necessary to untracked and unignored paths to
> match the working tree files, when they reset the index and the
> working tree to the named committish, may have made sense. If we
> were designing the feature without any existing users, it is no
> brainer to imagine that our design would: (1) call the three 'reset'
> modes as "both", "index-only" and "neither", instead of "hard",
> "mixed" and "soft", and (2) require "--force" to touch untracked and
> unignored paths.
>
> And I think that may be a reasonable longer-term goal, but since we
> have existing users and scripts, we cannot go there overnight without
> devising a migration path.
Sounds reasonable. I'm presuming that `read-tree --reset` is also an
oddball, but as plumbing it's better to keep its behavior as-is, i.e.
let it nuke untracked files/directories too. Let me know if you would
prefer otherwise.
I have a bunch of relatively small patches
(https://github.com/git/git/pull/1085, if you want a preview), which
fix most of the problems I found. I'm going to split it up into five
patch series, the first three of which are independent and shorter
than the remaining two.
prev parent reply other threads:[~2021-09-08 0:41 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAG2t84Uaw-Kdp+EXU8CY1QYfykFQj-hGLJnTSH8MYO8Vi_yqgA@mail.gmail.com>
2021-09-03 20:33 ` Aborting 'rebase main feat' removes unversioned files Fedor Biryukov
2021-09-04 6:57 ` Bagas Sanjaya
2021-09-04 9:48 ` Jeff King
2021-09-04 9:51 ` Fedor Biryukov
2021-09-04 9:58 ` Fedor Biryukov
2021-09-04 10:03 ` Fedor Biryukov
2021-09-04 10:24 ` Jeff King
2021-09-04 18:32 ` Fedor Biryukov
2021-09-04 10:18 ` Jeff King
2021-09-05 5:32 ` Elijah Newren
2021-09-05 7:43 ` Ævar Arnfjörð Bjarmason
2021-09-05 10:05 ` Fedor Biryukov
2021-09-08 0:40 ` Elijah Newren
2021-09-05 22:31 ` Junio C Hamano
2021-09-08 0:41 ` Elijah Newren [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='CABPp-BEvSFWN+sGA_0SSqH3sYKtHWs5YpOJSoCGQ_=e6rpfpyg@mail.gmail.com' \
--to=newren@gmail.com \
--cc=bagasdotme@gmail.com \
--cc=fedor.birjukov@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
/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).