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

Re: [PATCH 1/3] merge-tree -z: always show the original file name first

From
Elijah Newren <newren@gmail.com>
Date
Aug 20, 2022, 23:22 UTC
Message-ID
<CABPp-BH98_N4WrYUWTx8oOvfOWhEL+9sGnR8U2tRZjYUfzv1_Q@mail.gmail.com>
In-Reply-To
<44pr310n-rpr1-0660-0961-386rsq9q11o1@tzk.qr>

On Fri, Aug 19, 2022 at 2:17 AM Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:

Show 28 quoted lines
>
> Hi all (and I guess in particular Elijah),
>
> On Fri, 19 Aug 2022, Johannes Schindelin via GitGitGadget wrote:
>
> > diff --git a/t/t4069-remerge-diff.sh b/t/t4069-remerge-diff.sh
> > index 35f94957fce..bc580a242ac 100755
> > --- a/t/t4069-remerge-diff.sh
> > +++ b/t/t4069-remerge-diff.sh
> > @@ -131,11 +131,12 @@ test_expect_success 'setup non-content conflicts' '
> >  test_expect_success 'remerge-diff with non-content conflicts' '
> >       git log -1 --oneline resolution >tmp &&
> >       cat <<-EOF >>tmp &&
> > +     diff --git a/file_or_directory b/file_or_directory
> > +     remerge CONFLICT (file/directory): directory in the way of file_or_directory from HASH (side1); moving it to file_or_directory~HASH (side1) instead.
> >       diff --git a/file_or_directory~HASH (side1) b/wanted_content
> >       similarity index 100%
> >       rename from file_or_directory~HASH (side1)
> >       rename to wanted_content
> > -     remerge CONFLICT (file/directory): directory in the way of file_or_directory from HASH (side1); moving it to file_or_directory~HASH (side1) instead.
> >       diff --git a/letters b/letters
> >       remerge CONFLICT (rename/rename): letters renamed to letters_side1 in HASH (side1) and to letters_side2 in HASH (side2).
> >       diff --git a/letters_side2 b/letters_side2
>
> I would have liked to avoid touching this file altogether, of course, but
> when I investigated, I came to the conclusion that while this patch still
> does not produce the best possible outcome for remerge diffs, it does
> improve upon the current situation.

No, this is a strict regression. Those file headers corresponding to the file/directory conflict (similarity index, rename from/to, and CONFLICT) are all supposed to be grouped together in the same diff header. As to the names...

Show 17 quoted lines
> The thing is, when mentioning that we had to rename `file_or_directory` to
> `file_or_directory~HASH (side1)` to be able to write the file because a
> directory of the same name already was in the way, I would actually have
> expected this to come under the diff header
>
>         diff --git a/file_or_directory b/file_or_directory~HASH (side1)
>
> Previously, it was under the header
>
>         diff --git a/file_or_directory~HASH (side1) b/wanted_content
>
> and with this patch it is under
>
>         diff --git a/file_or_directory b/file_or_directory
>
> which is still not ideal: It mentions only the original file name, not the
> munged one.

The point of remerge-diff is to show how a user modifies from the auto-merged state to the final merge commit. As such, the filenames from before the merge starts are irrelevant; the only two relevant things are the filename at the end of the automatic merge, and the filename recorded in the commit.

In particular, for the case here, upon "git merge $BRANCH" the merge would have stopped with a file named "file_or_directory~HASH\ (side1)" present in the working copy[1]. The user resolved it via renaming that file to "wanted_content". As such, the first and third options you list are incorrect, and the second one -- from the behavior previous to your patch -- is correct.

[1] Technically, "git merge $BRANCH" would have used "HEAD" rather than "HASH (side1)", but that's only because at the time of invocation of git merge, HEAD would have been a very specific commit. The same isn't true of HEAD when the user runs `git log --remerge-diff` at some very different time, so we opt to replace "HEAD" with something more meaningful for readers of the diff when running --remerge-diff.

Previous: Johannes SchindelinNext: Elijah Newren
Message 4 of 12 in “Show original filenames in merge tree”
  1. 0/3 Show original filenames in merge treeJohannes Schindelin via GitGitGadget, Aug 19, 2022
  2. 1/3 merge-tree -z: always show the original file name firstJohannes Schindelin via GitGitGadget, Aug 19, 2022
  3. Johannes SchindelinAug 19, 2022
  4. Elijah NewrenAug 20, 2022
  5. Elijah NewrenAug 20, 2022
  6. Elijah NewrenAug 21, 2022
  7. Johannes SchindelinAug 22, 2022
  8. Elijah NewrenAug 23, 2022
  9. Johannes SchindelinAug 26, 2022
  10. Elijah NewrenAug 30, 2022
  11. 2/3 merge-tree: show the original file names in the conflict outputJohannes Schindelin via GitGitGadget, Aug 19, 2022
  12. 3/3 t4301: add a test case involving a rename, type change & modificationJohannes Schindelin via GitGitGadget, Aug 19, 2022

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.