diff options
author | Christian Halstrick <christian.halstrick@sap.com> | 2018-02-06 15:32:14 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2018-02-08 10:27:21 +0100 |
commit | 4d5231f0013d2b5239f00277475d3804be38366d (patch) | |
tree | 67a220c7da355e40c21e5cf5847ec18c4c7b1f4b /org.eclipse.jgit.test | |
parent | 93654f75a25d9af193731a97d2db675f57cc86bb (diff) | |
download | jgit-4d5231f0013d2b5239f00277475d3804be38366d.tar.gz jgit-4d5231f0013d2b5239f00277475d3804be38366d.zip |
Fix CleanCommand not to throw FileNotFoundExceptions
When CleanCommand is collecting the files and folders to be deleted
it may happen that the list of directories contains obsolete entries.
E.g. a folder and its parent folder may be in the list. Only the
parent folder would be sufficient.
This was a reason for hitting FileNotFoundExceptions when finally
trying to delete the files and folders. Improve CleanCommand
to ignore files to be deleted which are already gone.
Bug: 514434
Change-Id: I10caa01bfb9cec5967dfdaea50c6e4a713eeeabd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CleanCommandTest.java | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CleanCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CleanCommandTest.java index 85436db472..3921c96cdc 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CleanCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CleanCommandTest.java @@ -48,10 +48,12 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.io.File; +import java.io.IOException; import java.util.Set; import java.util.TreeSet; import org.eclipse.jgit.api.errors.GitAPIException; +import org.eclipse.jgit.api.errors.NoFilepatternException; import org.eclipse.jgit.errors.NoWorkTreeException; import org.eclipse.jgit.junit.RepositoryTestCase; import org.eclipse.jgit.lib.Repository; @@ -296,4 +298,18 @@ public class CleanCommandTest extends RepositoryTestCase { // The inner repository should be cleaned this time assertTrue(forceCleanedFiles.contains(innerRepoName + "/")); } + + @Test + // To proof Bug 514434. No assertions, but before the bugfix + // this test was throwing Exceptions + public void testFilesShouldBeCleanedInSubSubFolders() + throws IOException, NoFilepatternException, GitAPIException { + writeTrashFile(".gitignore", + "/ignored-dir\n/sub-noclean/Ignored.txt\n/this_is_ok\n/this_is/not_ok\n"); + git.add().addFilepattern(".gitignore").call(); + git.commit().setMessage("adding .gitignore").call(); + writeTrashFile("this_is_ok/more/subdirs/file.txt", "1"); + writeTrashFile("this_is/not_ok/more/subdirs/file.txt", "2"); + git.clean().setCleanDirectories(true).setIgnore(false).call(); + } } |