git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] RFC: switch: allow same-commit switch during merge if conflicts resolved

From
Elijah Newren <newren@gmail.com>
Date
May 3, 2023, 00:34 UTC
Message-ID
<CABPp-BEd_53EfEfFfWf8zEt0K7Mp4iMzN=q6smK4_08xfj6Tiw@mail.gmail.com>
In-Reply-To
<xmqq1qjy1xv2.fsf@gitster.g>
On Tue, May 2, 2023 at 9:50 AM Junio C Hamano <gitster@pobox.com> wrote:
Show 45 quoted lines
>
> Elijah Newren <newren@gmail.com> writes:
>
> > By the way, it was a problem that git-checkout wasn't updated to have
> > the same safety that git-switch has.  We should fix that.  (It's on my
> > todo list, along with adding other
> > prevent-erroneous-command-while-in-middle-of-other-operation cases.)
>
> Yes.
>
> > I'm worried this is likely to lead us into confusing UI mismatches,
> > and makes it harder to understand the appropriate rules of what can
> > and cannot be done.  A very simple "no switching branches in the
> > middle of operations" is a very simple rule, and saves users from lots
> > of headaches.
> >
> > Granted, expert users may understand that with the commit being the
> > same, there is no issue.  But expert users can use `git update-ref` to
> > tweak HEAD, or edit .git/HEAD directly, and accept the consequences.
> > Why do we need to confuse the UI for the sake of expert users who
> > already have an escape hatch?
> >
> > More importantly, though...
> >
> >> Change the behavior of "git switch" and "git checkout" to no longer delete
> >> merge metadata, nor prohibit the switch, if a merge is in progress and the
> >> commit being switched to is the same commit the HEAD was previously set to.
> >
> > Even if there are conflicts?  For rebases, cherry-picks, ams, and
> > reverts too?  (Does allowing this during rebases and whatnot mean that
> > --abort becomes really funny?  Does it mean that some commits are
> > applied to one branch, and all commits are applied to another?  What
> > about autostashes?  Does it interact weirdly with --update-refs?
> > etc.)
> >
> > I think this change is premature unless it discusses all these cases,
>
> It is pretty much what I wanted to say about why we haven't done
> this in <https://lore.kernel.org/git/xmqqpm7k6ojz.fsf@gitster.g/>,
> so it makes two of us ;-).  I didn't look at Tao's RFC patch but if
> the way it determines "we are in a middle of conflicted merge and
> we'll allow switching to the same commit only in this case" were
> "the index has an unmerged entry", then it is an overly broad test
> and the consequences of allowing the switch for these other merge-y
> operations that are ongoing must be evaluated.

He does tie it specifically to "is-this-a-merge-operation" (and actually doesn't check for conflicts at all since there are existing checks he leaves untouched). That certainly prevents some problems, but doesn't address my concerns.

I think the usecase Tao presents has multiple simple workarounds, and I'm worried that the particular proposal might paint us into a corner.

Personally, I think that before we consider a merge-specific-if-no-conflicts exception, someone should evaluate all the cases where exceptions could or should be allowed, get a documented story about them, and then if a consistent-ish UI is possible then propose patches to start taking us down this path.

Previous: Junio C HamanoNext: Tao Klerks
Message 4 of 17 in “RFC: switch: allow same-commit switch during merge if conflicts resolved”
  1. RFC: switch: allow same-commit switch during merge if conflicts resolvedTao Klerks via GitGitGadget, May 2, 2023
  2. Elijah NewrenMay 2, 2023
  3. Junio C HamanoMay 2, 2023
  4. Elijah NewrenMay 3, 2023
  5. Tao KlerksMay 4, 2023
  6. Tao KlerksMay 5, 2023
  7. Elijah NewrenMay 7, 2023
  8. Elijah NewrenMay 7, 2023
  9. Felipe ContrerasMay 7, 2023
  10. Tao KlerksMay 8, 2023
  11. Felipe ContrerasMay 8, 2023
  12. Tao KlerksMay 8, 2023
  13. Junio C HamanoMay 8, 2023
  14. Felipe ContrerasMay 9, 2023
  15. Tao KlerksMay 8, 2023
  16. Elijah NewrenMay 11, 2023
  17. Tao KlerksMay 21, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.