Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 354099

Summary: Merge "using strategy resolve resulted in: Failed." Pulls with conflicts also fail.
Product: [Technology] JGit Reporter: Braids Constance <eclipse.org-braids>
Component: JGitAssignee: Robin Stocker <robin>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: adietish, anton.kukushkin, catapl3xis, eclipse.org-braids, flood, hedefalk, jiri.dudek, jkwuc89, lbourgault_roy, maximilianmeier42, mooseroy, oman002, remy.suen, robin, stepper
Version: 2.0   
Target Milestone: 2.1-M1   
Hardware: PC   
OS: Windows XP   
URL: http://www.eclipse.org/forums/index.php/mv/msg/231804/711151/#msg_711151
Whiteboard:
Attachments:
Description Flags
Repo demonstrating 354099
none
output of log method
none
Commit error none

Description Braids Constance CLA 2011-08-07 20:33:33 EDT
Build Identifier: I20110613-1736

I have a workspace with nothing in the working directory and one commit. This commit is a single file which conflicts with the remote's head.

(git status) reports:
# On branch master
# Your branch and 'origin/master' have diverged,
# and have 1 and 74 different commit(s) each, respectively.
#
nothing to commit (working directory clean)

I tried to use EGit to merge using Team menu item, Merge item, Remote Tracking folder, origin/master (Ref), Merge button. I get the following error in a new window:

Multiple problems have occurred
(X) Merge of revisions abc..., 123..., with base def..., using strategy resolve resulted in: Failed. (hereafter known as (the same error message))

The white box in the window says:
(the same error message)
Merging with refs/remotes/origin/master

and the Details view shows (the same error message).


In Event Details, it shows the Date, the Severity is an Error, the Message is (the same error message), Exception Stack Trace is not available.
Session Data:
eclipse.buildId=I20110613-1736
java.version=1.6.0_26
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Command-line arguments: -os win32 -ws win32 -arch x86

How do I get EGit to show me a 3-way merge for the conflicting, committed file?

Pulls also fail miserably.  We have to resorted to another Git tool (SmartGit) to perform pulls (with merging).

Funny thing is, after using SmartGit to perform a pull with conflicting (non-automatic) changes, the double red arrows show up on the conflicting file and its parent folders in the Project View in EGit.

Reproducible: Always

Steps to Reproduce:
1. Modify a file that someone else has modified on Gitorious using SSH, but which you have not yet pulled.
2. Right click the project in the Project viewer.
3. Click the Team menu item.
4. Click the Merge menu item.
5. Open the Remote Tracking folder or category.
6. Click the origin/master reference.
7. Click the Merge button.
Comment 1 Braids Constance CLA 2011-08-07 20:36:32 EDT
Step 1 should read, "Modify and Commit a file..."
Comment 2 Jan Koops CLA 2011-10-25 05:28:25 EDT
We've got the same issue (1.1.0.201109151100-r)
- conflict markers show up,
- but repo-state is _not_ MERGING
- "Merge Tool" is unavailable.
Comment 3 Jan Koops CLA 2011-11-04 06:13:14 EDT
Seems only to affect files in the project root.
Comment 4 Jan Koops CLA 2011-11-22 02:20:13 EST
Steps to reproduce (tested version was egit-1.2.0.201111090740):
1. Clone http://egit.eclipse.org/r/p/egit-training.git
2. Create new branch "bug354099" at 51101ae160c68450deadc0acd0e662649e775541
3. Edit org.eclipse.example.calc/build.properties, eg. swap "tst" ans "src"
4. Merge with origin/master
Comment 5 Matthias Sohn CLA 2011-11-25 18:28:09 EST
(In reply to comment #4)
> Steps to reproduce (tested version was egit-1.2.0.201111090740):
> 1. Clone http://egit.eclipse.org/r/p/egit-training.git
> 2. Create new branch "bug354099" at 51101ae160c68450deadc0acd0e662649e775541
> 3. Edit org.eclipse.example.calc/build.properties, eg. swap "tst" ans "src"
> 4. Merge with origin/master

Tried this with todays nightly build (2011-11-25) and the merge went through without conflicts.
Maybe when you tried the repository was different ? We forcefully reset the training repository 
each time before we run another training.

Can you provide a sample repository and step by step instructions 
reproducing the problem for the sample repository ?
Comment 6 Jan Koops CLA 2011-11-30 01:15:28 EST
Created attachment 207700 [details]
Repo demonstrating 354099

To reproduce simply choose merge on master in history view.
Comment 7 maximilian meier CLA 2012-01-10 09:35:50 EST
I can reproduce the bug using the steps provided by Jan. 

1. Clone http://egit.eclipse.org/egit-training.git
2. Create new branch "bug354099" at 51101ae160c68450deadc0acd0e662649e775541
3. Edit org.eclipse.example.calc/build.properties; swap "tst" and "src"

   (Commited the changes <- this step was not mentioned by Jan, but was - I think - implied)

4. Merge with master via EGit fails with

!ENTRY org.eclipse.egit.ui 4 0 2012-01-10 12:58:27.635
!MESSAGE Merge of revisions 67a8d116c31aae5f4396c1a6a356fcce80c99cf8, 9c78d21c64ff5f66c122fbef43427f3e44b71447 
with base 51101ae160c68450deadc0acd0e662649e775541 using strategy resolve resulted in: Failed. 

now the repository is in no special state (no |Conflicts or any other markers on the repository name). however the git workspace
looks like you would expect it to when in state |Conflicts; conflicting files do have the ">>> HEAD === <<< theirs" conflict markers
and all incoming changes are listed under "Staged changes" in "Git staging" view. if you go on and resolve the conflicts, add the
conflicting files to the index and do a commit a *regular* commit is being done, not a merge commit.

If we repeat the above steps, but instead of using EGit, we use msysgit to merge this is the output:

Alle@MAX /E/gittraining/egit-training (bug354099)
$ git merge master
Auto-merging org.eclipse.example.calc/src/org/eclipse/example/calc/internal/ui/swing/CalculatorUI.java
Auto-merging org.eclipse.example.calc/build.properties
CONFLICT (content): Merge conflict in org.eclipse.example.calc/build.properties
Auto-merging org.eclipse.example.calc/SwingCalculatorUI.launch
Auto-merging org.eclipse.example.calc.test/tst/org/eclipse/example/calc/internal/operations/SquareTest.java
Auto-merging org.eclipse.example.calc.test/tst/org/eclipse/example/calc/OperationsTest.java
Auto-merging org.eclipse.example.calc.test/org.eclipse.example.calc--All-Tests.launch
Automatic merge failed; fix conflicts and then commit the result.

Alle@MAX /E/gittraining/egit-training (bug354099|MERGING)

now the repository is in the MERGE_CONFLICTS state, which is the expected/OK state. Now you can go back to eclipse. Egit will correctly see
that the repository has merge conflicts. You can resolve the conflicts, add the files to the index and commit. The commit will then be a 
*merge* commit as it is supposed to be.

From a top-down view it seems the only thing EGit fails to do is to put the repository the MERGE_CONFLICTS state 
and return a "Conflicting" merge result instead of the "Failed" one.

Environment used:

eclipse.buildId=M20110909-1335
java.version=1.6.0_29
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=de_DE
Command-line arguments:  -os win32 -ws win32 -arch x86 -data E:\zzzWorkspace


EGit (these versions were tested)
Stable release:
org.eclipse.jgit (1.2.0.201112221803-r) "JGit Core"
org.eclipse.egit (1.2.0.201112221803-r) "Git Team Provider"

Nightly build:
org.eclipse.jgit (1.3.0.201201090718) "JGit Core"
org.eclipse.egit (1.3.0.201201090723) "Git Team Provider"


msysgit
various versions tested, including "1.7.4.msysgit.0"; all worked the same)
Comment 8 maximilian meier CLA 2012-01-12 06:23:10 EST
Created attachment 209364 [details]
output of log method
Comment 9 maximilian meier CLA 2012-01-12 06:24:07 EST
I've been able to track the problem down to class org.eclipse.jgit.merge.ResolveMerger.
During the checkout JGit tries to delete non-empty folders which of course fails.
I changed method checkout to:  (version is 1.3.0.201201101327)

  private void checkout() throws NoWorkTreeException, IOException {
    ObjectReader r = db.getObjectDatabase().newReader();
    try {
      for (Map.Entry<String, DirCacheEntry> entry : toBeCheckedOut.entrySet()) {
+       log("toBeCheckedOut: " + entry.getKey() + "=" + entry.getValue()); 
        File f = new File(db.getWorkTree(), entry.getKey());
        if (entry.getValue() != null) {
          createDir(f.getParentFile());
          DirCacheCheckout.checkoutEntry(db, f, entry.getValue(), r);
        } else {
+         if (f.isDirectory()) {
+           log("Would delete folder " + f);
+         } else if (!f.delete()) {
-         if (!f.delete()) {
+           log("delete failed for " + f); 
            failingPaths.put(entry.getKey(),
                MergeFailureReason.COULD_NOT_DELETE);
          }
        }
        modifiedFiles.add(entry.getKey());
      }
    } finally {
      r.release();
    }
  }

The output of the log statements are in the attachment 209364 [details].
With my modification (not deleting any folder) 
EGit correctly reports the merge result CONFLICT instead of FAILED.
However, someone from the JGit/EGit team must check what's the real intention 
of the f.delete() statement and consider the case when f is a folder.
If folders are to be deleted, the proper sequence (child before parent) must be chosen. 
If folders are not to be deleted, something else is wrong which requires further analysis.
Comment 10 Paul Shtukov CLA 2012-03-23 10:46:15 EDT
Created attachment 213103 [details]
Commit error

I just had "untracked" & "ignored" one file.
Got "red cross" failure mesage, see attched image.
Had to delete file manualy from file system, then copy it again.

I think this issue is related to the bug of this topic, maybe it's related to addtion/deletion of files in repository.
Comment 11 Keith Wedinger CLA 2012-04-19 10:23:00 EDT
I ran into this same issue this morning when attempting to pull in changes from my Github repo into my local repo via EGit inside Eclipse.  The changes in the remote repo included a new directory named bin that contained several files and directories.  Inside my local repo, the bin directory is ignored because it is listed inside ~/gitignore_global.  Inside Eclipse, I removed the bin directory from my project.  Then, I attempted to do the pull again and this time, the pull from the remote repository properly displayed the result, "Merged".  Based on this, it appears that this bug may being caused by new files in the remote repository.
Comment 12 Anton Kukushkin CLA 2012-05-16 10:16:56 EDT
We're considering using eclipse together with git for our code base, and while testing out egit, bumped into this on our windows machines (two of them so far).
Comment 13 Laurent Bourgault-Roy CLA 2012-06-07 15:30:34 EDT
I can also confirm this bug where I work, on both a Mac OS X and a Windows 7 machine.

In the meantime, if you want a quick fix : When the "Failed" message appear, immediately do a hard reset of your workspace. Then redo the merge from a command-line. Go back to eclipse, and refresh. The workspace will correctly be in Conflicted mode, and the merge tool will be available. Not pretty, but it mostly work.
Comment 14 Robin Stocker CLA 2012-06-12 13:21:38 EDT
I can confirm that this is a bug in JGit -> changed the product to JGit.
Comment 15 Robin Stocker CLA 2012-06-12 13:23:04 EDT
The analysis in comment 9 is correct, pushed changes to fix this:

https://git.eclipse.org/r/6326
https://git.eclipse.org/r/6327
Comment 16 Robin Stocker CLA 2012-06-25 05:05:06 EDT
The fixes are now in master:

028434e4f58bfc154da2f56a68e7aefc220bb359
e623db0f876d95c9faae7ca089cb11c0bc2e6a7c

Please wait for the next nightly build to verify:

http://download.eclipse.org/egit/updates-nightly