@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));
+ assertEquals(2, result.getUpdatedFiles().size());
+ assertTrue(result.getUpdatedFiles().contains(new File(db.getWorkTree(), "RenameNoHunks")));
+ assertTrue(result.getUpdatedFiles().contains(new File(db.getWorkTree(), "nested/subdir/Renamed")));
checkFile(new File(db.getWorkTree(), "nested/subdir/Renamed"),
b.getString(0, b.size(), false));
}
@Test
public void testRenameWithHunks() throws Exception {
ApplyResult result = init("RenameWithHunks", true, true);
- assertEquals(1, result.getUpdatedFiles().size());
- assertEquals(new File(db.getWorkTree(), "RenameWithHunks"), result.getUpdatedFiles()
- .get(0));
+ assertEquals(2, result.getUpdatedFiles().size());
+ assertTrue(result.getUpdatedFiles().contains(new File(db.getWorkTree(), "RenameWithHunks")));
+ assertTrue(result.getUpdatedFiles().contains(new File(db.getWorkTree(), "nested/subdir/Renamed")));
checkFile(new File(db.getWorkTree(), "nested/subdir/Renamed"),
b.getString(0, b.size(), false));
}
public void testCopyWithHunks() throws Exception {
ApplyResult result = init("CopyWithHunks", true, true);
assertEquals(1, result.getUpdatedFiles().size());
- assertEquals(new File(db.getWorkTree(), "CopyWithHunks"), result.getUpdatedFiles()
+ assertEquals(new File(db.getWorkTree(), "CopyResult"), result.getUpdatedFiles()
.get(0));
checkFile(new File(db.getWorkTree(), "CopyResult"),
b.getString(0, b.size(), false));
JGitText.get().renameFileFailed, f, dest), e);
}
apply(repository, fh.getOldPath(), cache, dest, fh);
+ r.addUpdatedFile(dest);
break;
case COPY:
- f = getFile(fh.getOldPath(), false);
- File target = getFile(fh.getNewPath(), false);
- FileUtils.mkdirs(target.getParentFile(), true);
- Files.copy(f.toPath(), target.toPath());
- apply(repository, fh.getOldPath(), cache, target, fh);
+ File src = getFile(fh.getOldPath(), false);
+ f = getFile(fh.getNewPath(), false);
+ FileUtils.mkdirs(f.getParentFile(), true);
+ Files.copy(src.toPath(), f.toPath());
+ apply(repository, fh.getOldPath(), cache, f, fh);
}
r.addUpdatedFile(f);
}