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

Re: [PATCH 1/2] checkout: do not check out unmerged higher stages randomly

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 30, 2008, 18:02 UTC
Message-ID
<7v1w06ido7.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<7vbpzb4i1h.fsf@gitster.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 11 quoted lines
> During a conflicted merge when you have unmerged stages for a path F in
> the index, if you asked:
>
>     $ git checkout F
>
> we rewrote F as many times as we have stages for it, and the last one
> (typically "theirs") was left in the work tree, without resolving the
> conflict.
>
> This patch fixes it by noticing that a specified pathspec pattern matches
> an unmerged path, and by erroring out.

The patch claims that it is a bugfix, but I have a slight worry that somebody might be depending on this broken behaviour in their workflow.

    $ git pull
    Conflicts in foo.c (modify/modify)
    .. Eeek, conflicts.  My changes are always crap, and I trust my
    .. upstream more than I trust myself, so I'll take advantage of
    .. the bug to check out "their" version.
    $ git checkout foo.c

In modify/modify case, because we will have stage #3 (state after their change), that will be the version you will get as the final result of this broken behaviour of "checkout".

This patch alone will make the above to check out "theirs" an error. In a later one in the series, you can still say:

    $ git checkout --theirs foo.c ;# or "git checkout -3 foo.c"
to get the feature back, at the same time you will now be able to say
    $ git checkout --ours foo.c ;# or "git checkout -2 foo.c"

for symmetry (admittably, it is the same thing as "git checkout HEAD foo.c").

So we _could_ choose to stay backward compatible by leaving this "bug" unattended without loss of ability to checkout either theirs or ours, even though without fixing this, you cannot sanely add "git checkout -m foo.c" feature that comes later in the updated series, which allows you to go back to the original conflicted state after you (or rerere) messed up the working tree state.

Thoughts?
Previous: Junio C Hamano
Message 4 of 4 in “checkout: do not check out unmerged higher stages randomly”
  1. 1/2 checkout: do not check out unmerged higher stages randomlyJunio C Hamano, Aug 29, 2008
  2. 2/2 checkout: allow ignoring unmerged paths when checking out of the indexJunio C Hamano, Aug 29, 2008
  3. Junio C HamanoAug 29, 2008
  4. Junio C HamanoAug 30, 2008

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.