]> source.dussan.org Git - jgit.git/commitdiff
Failing to delete a directory with untracked content is actually ok 93/21493/3
authorRobin Rosenberg <robin.rosenberg@dewire.com>
Tue, 4 Feb 2014 00:00:41 +0000 (01:00 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Mon, 10 Feb 2014 10:25:02 +0000 (11:25 +0100)
We had a test, but it was wrong.

Bug: 424630
Change-Id: I926e0954c8623a323a50fe8be3ebe5e0ac6944c8
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/ResolveMergerTest.java
org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java

index 72762437d6eaec5fd9c4ff5039a69d87a423afcd..54de8cfb47bf9093668f1b81ffeb2fea6d2c6db1 100644 (file)
@@ -43,7 +43,6 @@
 package org.eclipse.jgit.merge;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 import java.io.File;
@@ -79,7 +78,7 @@ public class ResolveMergerTest extends RepositoryTestCase {
        public static MergeStrategy recursive = MergeStrategy.RECURSIVE;
 
        @Theory
-       public void failingPathsShouldNotResultInOKReturnValue(
+       public void failingDeleteOfDirectoryWithUntrackedContent(
                        MergeStrategy strategy) throws Exception {
                File folder1 = new File(db.getWorkTree(), "folder1");
                FileUtils.mkdir(folder1);
@@ -107,6 +106,7 @@ public class ResolveMergerTest extends RepositoryTestCase {
                RevCommit head = git.commit().setMessage("Adding another file").call();
 
                // Untracked file to cause failing path for delete() of folder1
+               // but that's ok.
                file = new File(folder1, "file3.txt");
                write(file, "folder1--file3.txt");
 
@@ -114,9 +114,8 @@ public class ResolveMergerTest extends RepositoryTestCase {
                merger.setCommitNames(new String[] { "BASE", "HEAD", "other" });
                merger.setWorkingTreeIterator(new FileTreeIterator(db));
                boolean ok = merger.merge(head.getId(), other.getId());
-
-               assertFalse(merger.getFailingPaths().isEmpty());
-               assertFalse(ok);
+               assertTrue(ok);
+               assertTrue(file.exists());
        }
 
        /**
index 710996d2a864aa7997f7ff6fcf1255f7cd5e00e6..eca2f91befddbf3c0f206d86054d4510ed210d9e 100644 (file)
@@ -244,8 +244,9 @@ public class ResolveMerger extends ThreeWayMerger {
                                String fileName = toBeDeleted.get(i);
                                File f = new File(db.getWorkTree(), fileName);
                                if (!f.delete())
-                                       failingPaths.put(fileName,
-                                                       MergeFailureReason.COULD_NOT_DELETE);
+                                       if (!f.isDirectory())
+                                               failingPaths.put(fileName,
+                                                               MergeFailureReason.COULD_NOT_DELETE);
                                modifiedFiles.add(fileName);
                        }
                } finally {