Re: 'git pull' complains that a locally resurrected directory would be overwritten by merge when no pulled changes are affecting that directory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Aug 26, 2021 at 6:05 PM Jeff King <peff@xxxxxxxx> wrote:
>
> On Wed, Aug 25, 2021 at 02:19:15PM -0700, Junio C Hamano wrote:
>
> > Elijah Newren <newren@xxxxxxxxx> writes:
> >
> > > ... allow if the incoming changes don't touch the same files), but
> > > local *staged* changes.  As per the merge manpage:
> > >
> > > """
> > > To avoid recording unrelated changes in the merge commit, git pull and
> > > git merge will also abort if there are any changes registered in the
> > > index relative to the HEAD commit.
> > > """
> > >
> > > While this particular example could theoretically be handled by the
> > > merge machinery without requiring the index match HEAD,...
> >
> > While I do not mind seeing a patch that loosens the condition ONLY
> > when the merge will cleanly auto-resolve without end-user
> > interaction, when any paths conflict and require editing by the
> > end-user, it is pretty much essential to require that the index
> > matches HEAD to keep "git merge" usable.
> >
> > This is because the final step to conclude such an "automated
> > procedure cannot cleanly resolve, so the end user helps resolving
> > with the editor and mark the resolved paths with 'git add' or 'git
> > rm'" session will become very error prone if we did not have the
> > requirement.  Not just the user MUST remember not to use "commit -a"
> > or "git add" a path that was already dirty in the working tree
> > before the merge started (which is the consequence of the current
> > requirement, which allows local changes to the unrelated working
> > tree files), they must MUST remember to somehow EXCLUDE the changes
> > already registered for unrelted paths from the concluded merge.
>
> Good point.
>
> In theory we could reject the merge only after finding that there were
> conflicts. That lets the happy path continue even with unrelated changes
> (just like a fast-forward does). I suspect we'd need to change the
> interface to the merge-backends, though (to say "do the merge, and bail
> on conflicts, but _don't_ write out conflict markers or touch any other
> state in that case").

We actually wouldn't need to change the interface.  One of the reasons
there were so many annoying bugs with index != HEAD, was that
builtin/merge.c stated that the merge backends were responsible for
enforcing that condition.  So every single merge backend had to be
individually fixed -- ours, octopus, resolve, recursive.  And then
some of those, like recursive, had multiple affected code paths, and
each one had to be fixed, and I didn't catch them all the first time.

That doesn't mean I'm in favor of the change, just pointing out that
one backend could decide to do this on its own even if the other
backends didn't support it.

> (I am just thinking out loud, though. My personal opinion is that if you
> have a bunch of staged changes and want to do any non-trivial merging,
> you should considering committing or stashing those changes).

Agreed.

Though perhaps I should have pointed out to Yuri that he wouldn't have
run into these problems if he would have used
    git restore --source={hash}~1 -- math/polymake
instead of
    git checkout {hash}~1 -- math/polymake

(since the former defaults to updating just the working directory,
while the later updates both the index and the working directory.)



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux