Bug 548813 - MergeTool with stage 2 as input should fall back to "working tree" after saved edits
Summary: MergeTool with stage 2 as input should fall back to "working tree" after save...
Status: RESOLVED FIXED
Alias: None
Product: EGit
Classification: Technology
Component: UI (show other bugs)
Version: 5.5   Edit
Hardware: All All
: P3 normal with 1 vote (vote)
Target Milestone: 5.12   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-01 02:44 EDT by Thomas Wolf CLA
Modified: 2021-06-02 12:02 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wolf CLA 2019-07-01 02:44:39 EDT
Steps to reproduce:

* Set in preferences "Team->Git", "Merge Tool content" = "Last HEAD (unmerged)"
* Produce a conflict
* Open merge tool (double click the conflicting file in staging view)
* Resolve conflict, save
* Double-click the file again in staging view (still in unstaged viewer)

Expected: merge tool uses modified working tree version of the file as "ours" input.

Actual: merge tool still uses stage 2 as input; doesn't show modifications made.

Not sure this can even be fixed reasonably. It would mean EGit would have to detect that the working tree file has been changed from the auto-merge version. The auto-merge version is not in the index.

Work-around: stage/unstage the file.
Comment 1 Eclipse Genie CLA 2021-04-17 13:40:37 EDT
New Gerrit change created: https://git.eclipse.org/r/c/egit/egit/+/179460
Comment 2 Thomas Wolf CLA 2021-04-17 14:26:49 EDT
While this Gerrit change does solve this particular problem, it got me thinking...

Why does EGit even _have_ the two options for the merge editor input at all?

Neither "Last HEAD (unmerged)" nor "Workspace (pre-merged by git)" is the correct input for the Eclipse merge editor. The 'ours' version doesn't have all the merges that git already did, so the user has to copy all non-conflicting changes himself again. The pre-merged workspace version has the git conflict markers, which makes conflict resolution in the merge editor more tedious than necessary.

The correct input for text files would be the workspace version as pre-merged by git, with all conflicts resolved to the 'ours' hunks. (I.e., what "git merge -X ours" would produce.) If that was the merge editor input, we wouldn't need either option.

This version could be produced by EGit either

* by running a "merge -X ours" via JGit once
  https://git.eclipse.org/r/c/jgit/jgit/+/179234 was in, or
* by processing the pre-merged working tree file, removing any "<<<<" marker and
  removing anything from "=====" to ">>>>>", including those markers.

The first approach might produce something else than C git's merge -X ours if the original merge was done via C git using other options (for instance, whitespace options).

The second approach would need to account for custom conflict markers. (The working tree file might have been produced by C git.)

@Matthias, what do you think?
Comment 3 Thomas Wolf CLA 2021-04-20 04:54:32 EDT
(In reply to Thomas Wolf from comment #2)
> * by processing the pre-merged working tree file, removing any "<<<<" marker
> and
>   removing anything from "=====" to ">>>>>", including those markers.
[...]
> @Matthias, what do you think?

A nice side-effect of this is that it will avoid problems with parsers falling over on invalid syntax (the git conflict markers) since these markers will simply no longer be in the input, so chances are much higher that the input is syntactically valid.
Comment 5 Eclipse Genie CLA 2021-06-02 04:42:32 EDT
New Gerrit change created: https://git.eclipse.org/r/c/egit/egit/+/181259