aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst/org/eclipse/jgit/api
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit/api')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ApplyCommandTest.java10
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java36
2 files changed, 46 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ApplyCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ApplyCommandTest.java
index 1dd329a9e7..714a54c90c 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ApplyCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ApplyCommandTest.java
@@ -111,6 +111,16 @@ public class ApplyCommandTest extends RepositoryTestCase {
}
@Test
+ public void testAddA3() throws Exception {
+ ApplyResult result = init("A3", false, true);
+ assertEquals(1, result.getUpdatedFiles().size());
+ assertEquals(new File(db.getWorkTree(), "A3"),
+ result.getUpdatedFiles().get(0));
+ checkFile(new File(db.getWorkTree(), "A3"),
+ b.getString(0, b.size(), false));
+ }
+
+ @Test
public void testAddA1Sub() throws Exception {
ApplyResult result = init("A1_sub", false, false);
assertEquals(1, result.getUpdatedFiles().size());
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java
index dd7230bdbf..563b32dab8 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java
@@ -194,6 +194,42 @@ public class ResetCommandTest extends RepositoryTestCase {
}
@Test
+ public void testHardResetWithConflicts_CreateFolder_UnstagedChanges() throws Exception {
+ setupRepository();
+
+ writeTrashFile("dir-or-file/c.txt", "content");
+ git.add().addFilepattern("dir-or-file/c.txt").call();
+ git.commit().setMessage("adding dir-or-file/c.txt").call();
+
+ FileUtils.delete(new File(db.getWorkTree(), "dir-or-file"), FileUtils.RECURSIVE);
+ writeTrashFile("dir-or-file", "content");
+
+ // bug 479266: cannot create folder "dir-or-file"
+ git.reset().setMode(ResetType.HARD).setRef(Constants.HEAD).call();
+ assertTrue(new File(db.getWorkTree(), "dir-or-file/c.txt").exists());
+ }
+
+ @Test
+ public void testHardResetWithConflicts_DeleteFolder_UnstagedChanges() throws Exception {
+ setupRepository();
+ ObjectId prevHead = db.resolve(Constants.HEAD);
+
+ writeTrashFile("dir-or-file/c.txt", "content");
+ git.add().addFilepattern("dir-or-file/c.txt").call();
+ git.commit().setMessage("adding dir-or-file/c.txt").call();
+
+ writeTrashFile("dir-or-file-2/d.txt", "content");
+ git.add().addFilepattern("dir-or-file-2/d.txt").call();
+ FileUtils.delete(new File(db.getWorkTree(), "dir-or-file-2"), FileUtils.RECURSIVE);
+ writeTrashFile("dir-or-file-2", "content");
+
+ // bug 479266: cannot delete folder "dir-or-file"
+ git.reset().setMode(ResetType.HARD).setRef(prevHead.getName()).call();
+ assertFalse(new File(db.getWorkTree(), "dir-or-file").exists());
+ assertFalse(new File(db.getWorkTree(), "dir-or-file-2").exists());
+ }
+
+ @Test
public void testResetToNonexistingHEAD() throws JGitInternalException,
AmbiguousObjectException, IOException, GitAPIException {