From cc00feaa8d0368f4a5caefa002025e2168f71a12 Mon Sep 17 00:00:00 2001 From: Robin Rosenberg Date: Mon, 8 Apr 2013 22:05:06 +0200 Subject: A deleted work tree file is not a conflict when merge wants to delete it Bug: 405199 Change-Id: I4b2ef3dc432d2fad8a6fabd1c8aec407b5c8c5ac Signed-off-by: Robin Rosenberg --- .../tst/org/eclipse/jgit/api/StashApplyCommandTest.java | 15 +++++++++++++++ .../src/org/eclipse/jgit/merge/ResolveMerger.java | 6 +++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StashApplyCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StashApplyCommandTest.java index 4dfac1447d..a81beb009a 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StashApplyCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StashApplyCommandTest.java @@ -543,4 +543,19 @@ public class StashApplyCommandTest extends RepositoryTestCase { assertNotNull(e.getMessage()); } } + + @Test + public void testApplyStashWithDeletedFile() throws Exception { + File file = writeTrashFile("file", "content"); + git.add().addFilepattern("file").call(); + git.commit().setMessage("x").call(); + file.delete(); + git.rm().addFilepattern("file").call(); + git.stashCreate().call(); + file.delete(); + + git.stashApply().setStashRef("stash@{0}").call(); + + assertFalse(file.exists()); + } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java b/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java index 2ea1160793..710996d2a8 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java @@ -488,7 +488,11 @@ public class ResolveMerger extends ThreeWayMerger { return true; } else if (modeT == 0 && modeB != 0) { // we want THEIRS ... but THEIRS contains the deletion of the - // file + // file. Also, do not complain if the file is already deleted + // locally. This complements the test in isWorktreeDirty() for + // the same case. + if (tw.getTreeCount() > T_FILE && tw.getRawMode(T_FILE) == 0) + return true; toBeDeleted.add(tw.getPathString()); return true; } -- cgit v1.2.3