Browse Source

Merge "A deleted work tree file is not a conflict when merge wants to delete it"

stable-3.0
Robin Rosenberg 12 years ago committed by Gerrit Code Review @ Eclipse.org
parent
commit
1c40d83f52
  1. 15
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StashApplyCommandTest.java
  2. 6
      org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java

15
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());
}
}

6
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;
}

Loading…
Cancel
Save