|
|
@ -43,11 +43,13 @@ |
|
|
|
|
|
|
|
|
|
|
|
package org.eclipse.jgit.lib; |
|
|
|
package org.eclipse.jgit.lib; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertEquals; |
|
|
|
import static org.junit.Assert.assertFalse; |
|
|
|
import static org.junit.Assert.assertFalse; |
|
|
|
import static org.junit.Assert.assertTrue; |
|
|
|
import static org.junit.Assert.assertTrue; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
import java.io.File; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.IOException; |
|
|
|
|
|
|
|
import java.util.Set; |
|
|
|
|
|
|
|
|
|
|
|
import org.eclipse.jgit.api.Git; |
|
|
|
import org.eclipse.jgit.api.Git; |
|
|
|
import org.eclipse.jgit.api.errors.GitAPIException; |
|
|
|
import org.eclipse.jgit.api.errors.GitAPIException; |
|
|
@ -118,6 +120,31 @@ public class IndexDiffSubmoduleTest extends RepositoryTestCase { |
|
|
|
assertTrue(indexDiff.diff()); |
|
|
|
assertTrue(indexDiff.diff()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void assertDiff(IndexDiff indexDiff, IgnoreSubmoduleMode mode, |
|
|
|
|
|
|
|
IgnoreSubmoduleMode... expectedEmptyModes) throws IOException { |
|
|
|
|
|
|
|
boolean diffResult = indexDiff.diff(); |
|
|
|
|
|
|
|
Set<String> submodulePaths = indexDiff |
|
|
|
|
|
|
|
.getPathsWithIndexMode(FileMode.GITLINK); |
|
|
|
|
|
|
|
boolean emptyExpected = false; |
|
|
|
|
|
|
|
for (IgnoreSubmoduleMode empty : expectedEmptyModes) { |
|
|
|
|
|
|
|
if (mode.equals(empty)) { |
|
|
|
|
|
|
|
emptyExpected = true; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (emptyExpected) { |
|
|
|
|
|
|
|
assertFalse("diff should be false with mode=" + mode, |
|
|
|
|
|
|
|
diffResult); |
|
|
|
|
|
|
|
assertEquals("should have no paths with FileMode.GITLINK", 0, |
|
|
|
|
|
|
|
submodulePaths.size()); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
assertTrue("diff should be true with mode=" + mode, |
|
|
|
|
|
|
|
diffResult); |
|
|
|
|
|
|
|
assertTrue("submodule path should have FileMode.GITLINK", |
|
|
|
|
|
|
|
submodulePaths.contains("modules/submodule")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Theory |
|
|
|
@Theory |
|
|
|
public void testDirtySubmoduleWorktree(IgnoreSubmoduleMode mode) |
|
|
|
public void testDirtySubmoduleWorktree(IgnoreSubmoduleMode mode) |
|
|
|
throws IOException { |
|
|
|
throws IOException { |
|
|
@ -125,13 +152,8 @@ public class IndexDiffSubmoduleTest extends RepositoryTestCase { |
|
|
|
IndexDiff indexDiff = new IndexDiff(db, Constants.HEAD, |
|
|
|
IndexDiff indexDiff = new IndexDiff(db, Constants.HEAD, |
|
|
|
new FileTreeIterator(db)); |
|
|
|
new FileTreeIterator(db)); |
|
|
|
indexDiff.setIgnoreSubmoduleMode(mode); |
|
|
|
indexDiff.setIgnoreSubmoduleMode(mode); |
|
|
|
if (mode.equals(IgnoreSubmoduleMode.ALL) |
|
|
|
assertDiff(indexDiff, mode, IgnoreSubmoduleMode.ALL, |
|
|
|
|| mode.equals(IgnoreSubmoduleMode.DIRTY)) |
|
|
|
IgnoreSubmoduleMode.DIRTY); |
|
|
|
assertFalse("diff should be false with mode=" + mode, |
|
|
|
|
|
|
|
indexDiff.diff()); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
assertTrue("diff should be true with mode=" + mode, |
|
|
|
|
|
|
|
indexDiff.diff()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Theory |
|
|
|
@Theory |
|
|
@ -145,12 +167,7 @@ public class IndexDiffSubmoduleTest extends RepositoryTestCase { |
|
|
|
IndexDiff indexDiff = new IndexDiff(db, Constants.HEAD, |
|
|
|
IndexDiff indexDiff = new IndexDiff(db, Constants.HEAD, |
|
|
|
new FileTreeIterator(db)); |
|
|
|
new FileTreeIterator(db)); |
|
|
|
indexDiff.setIgnoreSubmoduleMode(mode); |
|
|
|
indexDiff.setIgnoreSubmoduleMode(mode); |
|
|
|
if (mode.equals(IgnoreSubmoduleMode.ALL)) |
|
|
|
assertDiff(indexDiff, mode, IgnoreSubmoduleMode.ALL); |
|
|
|
assertFalse("diff should be false with mode=" + mode, |
|
|
|
|
|
|
|
indexDiff.diff()); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
assertTrue("diff should be true with mode=" + mode, |
|
|
|
|
|
|
|
indexDiff.diff()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Theory |
|
|
|
@Theory |
|
|
@ -163,13 +180,8 @@ public class IndexDiffSubmoduleTest extends RepositoryTestCase { |
|
|
|
IndexDiff indexDiff = new IndexDiff(db, Constants.HEAD, |
|
|
|
IndexDiff indexDiff = new IndexDiff(db, Constants.HEAD, |
|
|
|
new FileTreeIterator(db)); |
|
|
|
new FileTreeIterator(db)); |
|
|
|
indexDiff.setIgnoreSubmoduleMode(mode); |
|
|
|
indexDiff.setIgnoreSubmoduleMode(mode); |
|
|
|
if (mode.equals(IgnoreSubmoduleMode.ALL) |
|
|
|
assertDiff(indexDiff, mode, IgnoreSubmoduleMode.ALL, |
|
|
|
|| mode.equals(IgnoreSubmoduleMode.DIRTY)) |
|
|
|
IgnoreSubmoduleMode.DIRTY); |
|
|
|
assertFalse("diff should be false with mode=" + mode, |
|
|
|
|
|
|
|
indexDiff.diff()); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
assertTrue("diff should be true with mode=" + mode, |
|
|
|
|
|
|
|
indexDiff.diff()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Theory |
|
|
|
@Theory |
|
|
@ -183,13 +195,8 @@ public class IndexDiffSubmoduleTest extends RepositoryTestCase { |
|
|
|
IndexDiff indexDiff = new IndexDiff(db, Constants.HEAD, |
|
|
|
IndexDiff indexDiff = new IndexDiff(db, Constants.HEAD, |
|
|
|
new FileTreeIterator(db)); |
|
|
|
new FileTreeIterator(db)); |
|
|
|
indexDiff.setIgnoreSubmoduleMode(mode); |
|
|
|
indexDiff.setIgnoreSubmoduleMode(mode); |
|
|
|
if (mode.equals(IgnoreSubmoduleMode.ALL) |
|
|
|
assertDiff(indexDiff, mode, IgnoreSubmoduleMode.ALL, |
|
|
|
|| mode.equals(IgnoreSubmoduleMode.DIRTY)) |
|
|
|
IgnoreSubmoduleMode.DIRTY); |
|
|
|
assertFalse("diff should be false with mode=" + mode, |
|
|
|
|
|
|
|
indexDiff.diff()); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
assertTrue("diff should be true with mode=" + mode, |
|
|
|
|
|
|
|
indexDiff.diff()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Theory |
|
|
|
@Theory |
|
|
@ -200,13 +207,7 @@ public class IndexDiffSubmoduleTest extends RepositoryTestCase { |
|
|
|
IndexDiff indexDiff = new IndexDiff(db, Constants.HEAD, |
|
|
|
IndexDiff indexDiff = new IndexDiff(db, Constants.HEAD, |
|
|
|
new FileTreeIterator(db)); |
|
|
|
new FileTreeIterator(db)); |
|
|
|
indexDiff.setIgnoreSubmoduleMode(mode); |
|
|
|
indexDiff.setIgnoreSubmoduleMode(mode); |
|
|
|
if (mode.equals(IgnoreSubmoduleMode.ALL) |
|
|
|
assertDiff(indexDiff, mode, IgnoreSubmoduleMode.ALL, |
|
|
|
|| mode.equals(IgnoreSubmoduleMode.DIRTY) |
|
|
|
IgnoreSubmoduleMode.DIRTY, IgnoreSubmoduleMode.UNTRACKED); |
|
|
|
|| mode.equals(IgnoreSubmoduleMode.UNTRACKED)) |
|
|
|
|
|
|
|
assertFalse("diff should be false with mode=" + mode, |
|
|
|
|
|
|
|
indexDiff.diff()); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
assertTrue("diff should be true with mode=" + mode, |
|
|
|
|
|
|
|
indexDiff.diff()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|