summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst/org
diff options
context:
space:
mode:
authorJack Wickham <jwickham@palantir.com>2020-04-17 18:33:39 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2020-05-06 08:50:08 +0200
commitd69c0ef5bdadda57ac457e56f6ca0291131d8d9b (patch)
tree54f738968c0b26cfd55c5088a9f1a2a3b584212f /org.eclipse.jgit.test/tst/org
parent0a2a094feaac41966f3de22748d80d4d29a7ba30 (diff)
downloadjgit-d69c0ef5bdadda57ac457e56f6ca0291131d8d9b.tar.gz
jgit-d69c0ef5bdadda57ac457e56f6ca0291131d8d9b.zip
Create parent directories when renaming a file in ApplyCommand
Before this change, applying a patch will fail if the destination directory doesn't exist; after, the necessary parent directories are created. If renaming the file fails, the directories won't be deleted, so this change isn't atomic. However, ApplyCommand is already not atomic - if one hunk fails to apply, other hunks still get applied - so I don't think that is a blocker. Change-Id: Iea36138b806d4e7012176615bcc673756a82f365 Signed-off-by: Jack Wickham <jwickham@palantir.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst/org')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ApplyCommandTest.java10
1 files changed, 10 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 80bcb19d5e..fb320cb647 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
@@ -250,6 +250,16 @@ public class ApplyCommandTest extends RepositoryTestCase {
assertFalse(new File(db.getWorkTree(), "NonASCIIDel").exists());
}
+ @Test
+ public void testRenameNoHunks() throws Exception {
+ ApplyResult result = init("RenameNoHunks", true, true);
+ assertEquals(1, result.getUpdatedFiles().size());
+ assertEquals(new File(db.getWorkTree(), "RenameNoHunks"), result.getUpdatedFiles()
+ .get(0));
+ checkFile(new File(db.getWorkTree(), "nested/subdir/Renamed"),
+ b.getString(0, b.size(), false));
+ }
+
private static byte[] readFile(String patchFile) throws IOException {
final InputStream in = getTestResource(patchFile);
if (in == null) {