Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 343514 - PullCommand fails to pull a deleted file changed locally
Summary: PullCommand fails to pull a deleted file changed locally
Status: RESOLVED FIXED
Alias: None
Product: JGit
Classification: Technology
Component: JGit (show other bugs)
Version: 0.12   Edit
Hardware: PC Windows XP
: P3 critical (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL: http://egit.eclipse.org/r/3197
Whiteboard:
Keywords:
Depends on:
Blocks: 343198
  Show dependency tree
 
Reported: 2011-04-21 07:17 EDT by Tomasz Zarna CLA
Modified: 2011-06-13 06:46 EDT (History)
3 users (show)

See Also:


Attachments
failing test cases (4.20 KB, patch)
2011-04-21 07:19 EDT, Tomasz Zarna CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tomasz Zarna CLA 2011-04-21 07:17:13 EDT
Unless I'm doing something wrong, PullCommand doesn't give proper results when pulling a file is deleted on one side (local or remote) and modified on the other.

Case 1, steps:
1. Have two clones: "source" and "target" (clone of "source") with "file.txt"
2. In source: "rm file.txt", "git rm file.txt", "git commit -m 'remove file'"
3. In target: modify "file.txt", "git add .", "git commit -m 'change file'"
4. In target: "git pull"
=> SHOULD BE: merge status saying "Conflicting"
=> IS (according to test, see attachment): "Merged"

Case 2, steps:
1. Have two clones: "source" and "target" (clone of "source") with "file.txt"
2. In source: modify "file.txt", "git add .", "git commit -m 'change file'"
3. In target: "rm file.txt", "git rm file.txt", "git commit -m 'remove file'"
4. In target: "git pull"
=> SHOULD BE: merge status saying "Conflicting"
=> IS (according to test, see attachment): 

org.eclipse.jgit.api.errors.JGitInternalException: Exception caught during execution of merge command. org.eclipse.jgit.errors.CheckoutConflictException: Checkout conflict with files: 
SomeFile.txt
	at org.eclipse.jgit.api.MergeCommand.call(MergeCommand.java:251)
	at org.eclipse.jgit.api.PullCommand.call(PullCommand.java:286)
	at org.eclipse.jgit.api.PullCommandTest.testPullDeletedChange(PullCommandTest.java:243)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
	at java.lang.reflect.Method.invoke(Method.java:600)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
	at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.eclipse.jgit.errors.CheckoutConflictException: Checkout conflict with files: 
SomeFile.txt
	at org.eclipse.jgit.dircache.DirCacheCheckout.checkout(DirCacheCheckout.java:387)
	at org.eclipse.jgit.api.MergeCommand.call(MergeCommand.java:220)
	... 27 more
Comment 1 Tomasz Zarna CLA 2011-04-21 07:19:33 EDT
Created attachment 193803 [details]
failing test cases

I will try to upload it to Gerrit in a minute.
Comment 2 Tomasz Zarna CLA 2011-04-21 07:26:54 EDT
http://egit.eclipse.org/r/3197
Comment 3 Stefan Lay CLA 2011-04-28 05:14:20 EDT
Actually it is the other way round: Case 1 leads to an exception, case 2 does the merge.

Native git gives the following results:

Case 1: 
ICT (delete/modify): file.txt deleted in a31114d09de0b55d775d96d0058492c61730fadf and modified in HEAD. Version HEAD of
atic merge failed; fix conflicts and then commit the result.

Case 2:
ICT (delete/modify): file.txt deleted in HEAD and modified in 24a7d882d6a830fcd0e631e200900c1884bede2b. Version 24a7d882d6a8
atic merge failed; fix conflicts and then commit the result.


The error is in class DirCacheCheckout.
Comment 4 John Arthorne CLA 2011-04-28 13:06:29 EDT
Increasing severity. When we hit this in Orion we have no way to resolve the conflict without resorting to git command line.
Comment 5 Tomasz Zarna CLA 2011-06-10 07:02:58 EDT
It looks that one case has been fixed in http://egit.eclipse.org/r/#change,3294, but the other is still failing.
Comment 6 Tomasz Zarna CLA 2011-06-13 06:46:09 EDT
(In reply to comment #5)
> It looks that one case has been fixed in http://egit.eclipse.org/r/#change,3294,
> but the other is still failing.

After examining the failing test it turned out it contained a typo. The latest patch set on http://egit.eclipse.org/r/3197 has it fixed... and all tests pass now. So it looks that  http://egit.eclipse.org/r/#change,3294 (no bug number) fixed both cases.