summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorTomasz Zarna2011-06-20 12:17:56 (EDT)
committer Stefan Lay2011-07-13 09:42:33 (EDT)
commite15037b3c7aa7f72313f19086bce12c54617c1bb (patch)
tree80c43208d6d39a3cf5823760d55de38170b0f526
parent1d1f5727716bf8626869064812a05a3e39e1d0f2 (diff)
downloadjgit-e15037b3c7aa7f72313f19086bce12c54617c1bb.zip
jgit-e15037b3c7aa7f72313f19086bce12c54617c1bb.tar.gz
jgit-e15037b3c7aa7f72313f19086bce12c54617c1bb.tar.bz2
Merge doesn't remove empty foldersrefs/changes/56/3756/2
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java41
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java2
2 files changed, 42 insertions, 1 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java
index 39526e2..7811706 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java
@@ -60,6 +60,7 @@ import org.eclipse.jgit.lib.RepositoryTestCase;
import org.eclipse.jgit.merge.MergeStrategy;
import org.eclipse.jgit.merge.ResolveMerger.MergeFailureReason;
import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.jgit.util.FileUtils;
import org.junit.Test;
public class MergeCommandTest extends RepositoryTestCase {
@@ -916,6 +917,46 @@ public class MergeCommandTest extends RepositoryTestCase {
indexState, fileA);
}
+ @Test
+ public void testMergeRemovingFolders() throws Exception {
+ File folder1 = new File(db.getWorkTree(), "folder1");
+ File folder2 = new File(db.getWorkTree(), "folder2");
+ FileUtils.mkdir(folder1);
+ FileUtils.mkdir(folder2);
+ File file = new File(folder1, "file1.txt");
+ write(file, "folder1--file1.txt");
+ file = new File(folder1, "file2.txt");
+ write(file, "folder1--file2.txt");
+ file = new File(folder2, "file1.txt");
+ write(file, "folder--file1.txt");
+ file = new File(folder2, "file2.txt");
+ write(file, "folder2--file2.txt");
+
+ Git git = new Git(db);
+ git.add().addFilepattern(folder1.getName())
+ .addFilepattern(folder2.getName()).call();
+ RevCommit commit1 = git.commit().setMessage("adding folders").call();
+
+ recursiveDelete(folder1);
+ recursiveDelete(folder2);
+ git.rm().addFilepattern("folder1/file1.txt")
+ .addFilepattern("folder1/file2.txt")
+ .addFilepattern("folder2/file1.txt")
+ .addFilepattern("folder2/file2.txt").call();
+ RevCommit commit2 = git.commit()
+ .setMessage("removing folders on 'branch'").call();
+
+ git.checkout().setName(commit1.name()).call();
+
+ MergeResult result = git.merge().include(commit2.getId())
+ .setStrategy(MergeStrategy.RESOLVE).call();
+ assertEquals(MergeResult.MergeStatus.FAST_FORWARD,
+ result.getMergeStatus());
+ assertEquals(commit2, result.getNewHead());
+ assertFalse(folder1.exists());
+ assertFalse(folder2.exists());
+ }
+
private RevCommit addAllAndCommit(final Git git) throws Exception {
git.add().addFilepattern(".").call();
return git.commit().setMessage("message").call();
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java
index 6a1669b..79f2297 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java
@@ -414,7 +414,7 @@ public class DirCacheCheckout {
toBeDeleted.add(r);
else {
if (!isSamePrefix(r, last))
- removeEmptyParents(file);
+ removeEmptyParents(new File(repo.getWorkTree(), last));
last = r;
}
}