|
|
|
@ -148,8 +148,9 @@ public class IndexDiffTest extends RepositoryTestCase {
|
|
|
|
|
writeTrashFile("file2", "file2"); |
|
|
|
|
writeTrashFile("dir/file3", "dir/file3"); |
|
|
|
|
|
|
|
|
|
Git git = new Git(db); |
|
|
|
|
try (Git git = new Git(db)) { |
|
|
|
|
git.add().addFilepattern("file2").addFilepattern("dir/file3").call(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
writeTrashFile("dir/file3", "changed"); |
|
|
|
|
|
|
|
|
@ -177,8 +178,7 @@ public class IndexDiffTest extends RepositoryTestCase {
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testConflicting() throws Exception { |
|
|
|
|
Git git = new Git(db); |
|
|
|
|
|
|
|
|
|
try (Git git = new Git(db)) { |
|
|
|
|
writeTrashFile("a", "1\na\n3\n"); |
|
|
|
|
writeTrashFile("b", "1\nb\n3\n"); |
|
|
|
|
git.add().addFilepattern("a").addFilepattern("b").call(); |
|
|
|
@ -202,6 +202,7 @@ public class IndexDiffTest extends RepositoryTestCase {
|
|
|
|
|
MergeResult result = git.merge().include(secondCommit.getId()) |
|
|
|
|
.setStrategy(MergeStrategy.RESOLVE).call(); |
|
|
|
|
assertEquals(MergeStatus.CONFLICTING, result.getMergeStatus()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
FileTreeIterator iterator = new FileTreeIterator(db); |
|
|
|
|
IndexDiff diff = new IndexDiff(db, Constants.HEAD, iterator); |
|
|
|
@ -221,8 +222,7 @@ public class IndexDiffTest extends RepositoryTestCase {
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testConflictingDeletedAndModified() throws Exception { |
|
|
|
|
Git git = new Git(db); |
|
|
|
|
|
|
|
|
|
try (Git git = new Git(db)) { |
|
|
|
|
writeTrashFile("a", "1\na\n3\n"); |
|
|
|
|
writeTrashFile("b", "1\nb\n3\n"); |
|
|
|
|
git.add().addFilepattern("a").addFilepattern("b").call(); |
|
|
|
@ -244,6 +244,7 @@ public class IndexDiffTest extends RepositoryTestCase {
|
|
|
|
|
MergeResult result = git.merge().include(secondCommit.getId()) |
|
|
|
|
.setStrategy(MergeStrategy.RESOLVE).call(); |
|
|
|
|
assertEquals(MergeStatus.CONFLICTING, result.getMergeStatus()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
FileTreeIterator iterator = new FileTreeIterator(db); |
|
|
|
|
IndexDiff diff = new IndexDiff(db, Constants.HEAD, iterator); |
|
|
|
@ -262,8 +263,7 @@ public class IndexDiffTest extends RepositoryTestCase {
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testConflictingFromMultipleCreations() throws Exception { |
|
|
|
|
Git git = new Git(db); |
|
|
|
|
|
|
|
|
|
try (Git git = new Git(db)) { |
|
|
|
|
writeTrashFile("a", "1\na\n3\n"); |
|
|
|
|
git.add().addFilepattern("a").call(); |
|
|
|
|
RevCommit initialCommit = git.commit().setMessage("initial").call(); |
|
|
|
@ -284,6 +284,7 @@ public class IndexDiffTest extends RepositoryTestCase {
|
|
|
|
|
MergeResult result = git.merge().include(secondCommit.getId()) |
|
|
|
|
.setStrategy(MergeStrategy.RESOLVE).call(); |
|
|
|
|
assertEquals(MergeStatus.CONFLICTING, result.getMergeStatus()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
FileTreeIterator iterator = new FileTreeIterator(db); |
|
|
|
|
IndexDiff diff = new IndexDiff(db, Constants.HEAD, iterator); |
|
|
|
@ -304,11 +305,12 @@ public class IndexDiffTest extends RepositoryTestCase {
|
|
|
|
|
writeTrashFile("a.c", "a.c"); |
|
|
|
|
writeTrashFile("a=c", "a=c"); |
|
|
|
|
writeTrashFile("a=d", "a=d"); |
|
|
|
|
Git git = new Git(db); |
|
|
|
|
try (Git git = new Git(db)) { |
|
|
|
|
git.add().addFilepattern("a.b").call(); |
|
|
|
|
git.add().addFilepattern("a.c").call(); |
|
|
|
|
git.add().addFilepattern("a=c").call(); |
|
|
|
|
git.add().addFilepattern("a=d").call(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TreeFormatter tree = new TreeFormatter(); |
|
|
|
|
// got the hash id'd from the data using echo -n a.b|git hash-object -t blob --stdin
|
|
|
|
@ -338,7 +340,6 @@ public class IndexDiffTest extends RepositoryTestCase {
|
|
|
|
|
*/ |
|
|
|
|
@Test |
|
|
|
|
public void testUnchangedComplex() throws IOException, GitAPIException { |
|
|
|
|
Git git = new Git(db); |
|
|
|
|
writeTrashFile("a.b", "a.b"); |
|
|
|
|
writeTrashFile("a.c", "a.c"); |
|
|
|
|
writeTrashFile("a/b.b/b", "a/b.b/b"); |
|
|
|
@ -346,10 +347,12 @@ public class IndexDiffTest extends RepositoryTestCase {
|
|
|
|
|
writeTrashFile("a/c", "a/c"); |
|
|
|
|
writeTrashFile("a=c", "a=c"); |
|
|
|
|
writeTrashFile("a=d", "a=d"); |
|
|
|
|
try (Git git = new Git(db)) { |
|
|
|
|
git.add().addFilepattern("a.b").addFilepattern("a.c") |
|
|
|
|
.addFilepattern("a/b.b/b").addFilepattern("a/b") |
|
|
|
|
.addFilepattern("a/c").addFilepattern("a=c") |
|
|
|
|
.addFilepattern("a=d").call(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// got the hash id'd from the data using echo -n a.b|git hash-object -t blob --stdin
|
|
|
|
@ -397,11 +400,12 @@ public class IndexDiffTest extends RepositoryTestCase {
|
|
|
|
|
*/ |
|
|
|
|
@Test |
|
|
|
|
public void testRemovedUntracked() throws Exception{ |
|
|
|
|
Git git = new Git(db); |
|
|
|
|
String path = "file"; |
|
|
|
|
try (Git git = new Git(db)) { |
|
|
|
|
writeTrashFile(path, "content"); |
|
|
|
|
git.add().addFilepattern(path).call(); |
|
|
|
|
git.commit().setMessage("commit").call(); |
|
|
|
|
} |
|
|
|
|
removeFromIndex(path); |
|
|
|
|
FileTreeIterator iterator = new FileTreeIterator(db); |
|
|
|
|
IndexDiff diff = new IndexDiff(db, Constants.HEAD, iterator); |
|
|
|
@ -417,8 +421,7 @@ public class IndexDiffTest extends RepositoryTestCase {
|
|
|
|
|
*/ |
|
|
|
|
@Test |
|
|
|
|
public void testUntrackedFolders() throws Exception { |
|
|
|
|
Git git = new Git(db); |
|
|
|
|
|
|
|
|
|
try (Git git = new Git(db)) { |
|
|
|
|
IndexDiff diff = new IndexDiff(db, Constants.HEAD, |
|
|
|
|
new FileTreeIterator(db)); |
|
|
|
|
diff.diff(); |
|
|
|
@ -463,6 +466,7 @@ public class IndexDiffTest extends RepositoryTestCase {
|
|
|
|
|
"target")), |
|
|
|
|
diff.getUntrackedFolders()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Test that ignored folders aren't listed as untracked |
|
|
|
@ -471,8 +475,7 @@ public class IndexDiffTest extends RepositoryTestCase {
|
|
|
|
|
*/ |
|
|
|
|
@Test |
|
|
|
|
public void testUntrackedNotIgnoredFolders() throws Exception { |
|
|
|
|
Git git = new Git(db); |
|
|
|
|
|
|
|
|
|
try (Git git = new Git(db)) { |
|
|
|
|
IndexDiff diff = new IndexDiff(db, Constants.HEAD, |
|
|
|
|
new FileTreeIterator(db)); |
|
|
|
|
diff.diff(); |
|
|
|
@ -510,10 +513,11 @@ public class IndexDiffTest extends RepositoryTestCase {
|
|
|
|
|
"target")), |
|
|
|
|
diff.getUntrackedFolders()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testAssumeUnchanged() throws Exception { |
|
|
|
|
Git git = new Git(db); |
|
|
|
|
try (Git git = new Git(db)) { |
|
|
|
|
String path = "file"; |
|
|
|
|
writeTrashFile(path, "content"); |
|
|
|
|
git.add().addFilepattern(path).call(); |
|
|
|
@ -551,6 +555,7 @@ public class IndexDiffTest extends RepositoryTestCase {
|
|
|
|
|
assertTrue(diff.getChanged().contains("file")); |
|
|
|
|
assertEquals(Collections.EMPTY_SET, diff.getUntrackedFolders()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testStageState() throws IOException { |
|
|
|
@ -575,8 +580,7 @@ public class IndexDiffTest extends RepositoryTestCase {
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testStageState_mergeAndReset_bug() throws Exception { |
|
|
|
|
Git git = new Git(db); |
|
|
|
|
|
|
|
|
|
try (Git git = new Git(db)) { |
|
|
|
|
writeTrashFile("a", "content"); |
|
|
|
|
git.add().addFilepattern("a").call(); |
|
|
|
|
RevCommit initialCommit = git.commit().setMessage("initial commit") |
|
|
|
@ -635,11 +639,11 @@ public class IndexDiffTest extends RepositoryTestCase {
|
|
|
|
|
.get("b")); |
|
|
|
|
assertTrue(diff.getUntrackedFolders().isEmpty()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testStageState_simulated_bug() throws Exception { |
|
|
|
|
Git git = new Git(db); |
|
|
|
|
|
|
|
|
|
try (Git git = new Git(db)) { |
|
|
|
|
writeTrashFile("a", "content"); |
|
|
|
|
git.add().addFilepattern("a").call(); |
|
|
|
|
RevCommit initialCommit = git.commit().setMessage("initial commit") |
|
|
|
@ -688,10 +692,11 @@ public class IndexDiffTest extends RepositoryTestCase {
|
|
|
|
|
.get("b")); |
|
|
|
|
assertTrue(diff.getUntrackedFolders().isEmpty()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testAutoCRLFInput() throws Exception { |
|
|
|
|
Git git = new Git(db); |
|
|
|
|
try (Git git = new Git(db)) { |
|
|
|
|
FileBasedConfig config = db.getConfig(); |
|
|
|
|
|
|
|
|
|
// Make sure core.autocrlf is false before adding
|
|
|
|
@ -717,6 +722,7 @@ public class IndexDiffTest extends RepositoryTestCase {
|
|
|
|
|
"Expected no modified files, but there were: " |
|
|
|
|
+ diff.getModified(), diff.getModified().isEmpty()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void verifyStageState(StageState expected, int... stages) |
|
|
|
|
throws IOException { |
|
|
|
|