diff options
author | Han-Wen Nienhuys <hanwen@google.com> | 2022-08-08 17:49:14 +0200 |
---|---|---|
committer | Han-Wen Nienhuys <hanwen@google.com> | 2022-08-08 18:38:23 +0200 |
commit | 3b4a636183609e2c4090cc6bdbbd8fecb2789a4e (patch) | |
tree | a5c546a521d7eae4a616469c81cfff372614f412 | |
parent | 5709317f71ccaf26eceaa896150f203879b634b8 (diff) | |
download | jgit-3b4a636183609e2c4090cc6bdbbd8fecb2789a4e.tar.gz jgit-3b4a636183609e2c4090cc6bdbbd8fecb2789a4e.zip |
ResolveMerger: add coverage for inCore file => directory transition
Change-Id: I6c3473932eb418a036f5943c78e619184559ef3a
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergerTest.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergerTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergerTest.java index cbacaed728..dc119c90ff 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergerTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergerTest.java @@ -1002,6 +1002,39 @@ public class MergerTest extends RepositoryTestCase { } } + @Theory + public void fileBecomesDir_noTree(MergeStrategy strategy) + throws Exception { + Git git = Git.wrap(db); + + writeTrashFile("file", "1\n2\n3"); + writeTrashFile("side", "1\n2\n3"); + git.add().addFilepattern("file").addFilepattern("side").call(); + RevCommit first = git.commit().setMessage("base").call(); + + writeTrashFile("side", "our changed"); + RevCommit ours = git.commit().setAll(true) + .setMessage("ours").call(); + + git.checkout().setCreateBranch(true).setStartPoint(first) + .setName("theirs").call(); + deleteTrashFile("file"); + writeTrashFile("file/file", "in subdir"); + git.add().addFilepattern("file/file").call(); + + RevCommit theirs = git.commit().setAll(true) + .setMessage("theirs").call(); + + // Exercise inCore flavor of the merge. + try (ObjectInserter ins = db.newObjectInserter()) { + ResolveMerger merger = + (ResolveMerger) strategy.newMerger(ins, db.getConfig()); + boolean success = merger.merge(ours, theirs); + assertTrue(success); + assertTrue(merger.getModifiedFiles().isEmpty()); + } + } + /** * Merging after criss-cross merges. In this case we merge together two * commits which have two equally good common ancestors |