aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst/org/eclipse/jgit/api
diff options
context:
space:
mode:
authorChristian Halstrick <christian.halstrick@sap.com>2016-09-27 15:38:53 +0200
committerChristian Halstrick <christian.halstrick@sap.com>2016-09-27 15:58:24 +0200
commit83e43f7960de7e62dd1e7b2950ceed24ce85e8ac (patch)
treedfa9024397dcc9853971d9ba5908c5e61b833e39 /org.eclipse.jgit.test/tst/org/eclipse/jgit/api
parent8ed16fa1005405837cbb6f515333f89dbda876f5 (diff)
downloadjgit-83e43f7960de7e62dd1e7b2950ceed24ce85e8ac.tar.gz
jgit-83e43f7960de7e62dd1e7b2950ceed24ce85e8ac.zip
Fix CheckoutCommand to return updated files even on NONDELETED status
CheckoutCommand was not returning updated and removed files in case of an overall status of NONDELETED. That's status which occurs especially on the Windows platform when Checkout wanted to delete files but the filesystem doesn't allow this. The situation is more seldom on linux/mac because open filehandles don't stop a deletion attempt and checkout succeeds more often. Change-Id: I4828008e58c09bd8f9edaf0f7eda0a79c629fb57
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit/api')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java33
1 files changed, 33 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java
index 998b5fbfc2..3c196724a9 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java
@@ -89,6 +89,7 @@ import org.eclipse.jgit.transport.RefSpec;
import org.eclipse.jgit.transport.RemoteConfig;
import org.eclipse.jgit.transport.URIish;
import org.eclipse.jgit.util.FileUtils;
+import org.eclipse.jgit.util.SystemReader;
import org.junit.Before;
import org.junit.Test;
@@ -791,6 +792,38 @@ public class CheckoutCommandTest extends RepositoryTestCase {
}
}
+ @Test
+ public void testNonDeletableFilesOnWindows()
+ throws GitAPIException, IOException {
+ // Only on windows a FileInputStream blocks us from deleting a file
+ org.junit.Assume.assumeTrue(SystemReader.getInstance().isWindows());
+ writeTrashFile("toBeModified.txt", "a");
+ writeTrashFile("toBeDeleted.txt", "a");
+ git.add().addFilepattern(".").call();
+ RevCommit addFiles = git.commit().setMessage("add more files").call();
+
+ git.rm().setCached(false).addFilepattern("Test.txt")
+ .addFilepattern("toBeDeleted.txt").call();
+ writeTrashFile("toBeModified.txt", "b");
+ writeTrashFile("toBeCreated.txt", "a");
+ git.add().addFilepattern(".").call();
+ RevCommit crudCommit = git.commit().setMessage("delete, modify, add")
+ .call();
+ git.checkout().setName(addFiles.getName()).call();
+ try ( FileInputStream fis=new FileInputStream(new File(db.getWorkTree(), "Test.txt")) ) {
+ CheckoutCommand coCommand = git.checkout();
+ coCommand.setName(crudCommit.getName()).call();
+ CheckoutResult result = coCommand.getResult();
+ assertEquals(Status.NONDELETED, result.getStatus());
+ assertEquals("[Test.txt, toBeDeleted.txt]",
+ result.getRemovedList().toString());
+ assertEquals("[toBeCreated.txt, toBeModified.txt]",
+ result.getModifiedList().toString());
+ assertEquals("[Test.txt]", result.getUndeletedList().toString());
+ assertTrue(result.getConflictList().isEmpty());
+ }
+ }
+
private File writeTempFile(String body) throws IOException {
File f = File.createTempFile("AddCommandTest_", "");
JGitTestUtil.write(f, body);