|
|
@ -155,6 +155,18 @@ public class StashCreateCommandTest extends RepositoryTestCase { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<DiffEntry> diffIndexAgainstWorking(final RevCommit commit) |
|
|
|
|
|
|
|
throws IOException { |
|
|
|
|
|
|
|
TreeWalk walk = createTreeWalk(); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
walk.addTree(commit.getParent(1).getTree()); |
|
|
|
|
|
|
|
walk.addTree(commit.getTree()); |
|
|
|
|
|
|
|
return DiffEntry.scan(walk); |
|
|
|
|
|
|
|
} finally { |
|
|
|
|
|
|
|
walk.release(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void noLocalChanges() throws Exception { |
|
|
|
public void noLocalChanges() throws Exception { |
|
|
|
assertNull(git.stashCreate().call()); |
|
|
|
assertNull(git.stashCreate().call()); |
|
|
@ -194,6 +206,26 @@ public class StashCreateCommandTest extends RepositoryTestCase { |
|
|
|
assertEquals("file2.txt", diffs.get(0).getNewPath()); |
|
|
|
assertEquals("file2.txt", diffs.get(0).getNewPath()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
public void newFileInIndexThenModifiedInWorkTree() throws Exception { |
|
|
|
|
|
|
|
writeTrashFile("file", "content"); |
|
|
|
|
|
|
|
git.add().addFilepattern("file").call(); |
|
|
|
|
|
|
|
writeTrashFile("file", "content2"); |
|
|
|
|
|
|
|
RevCommit stashedWorkTree = Git.wrap(db).stashCreate().call(); |
|
|
|
|
|
|
|
validateStashedCommit(stashedWorkTree); |
|
|
|
|
|
|
|
RevWalk walk = new RevWalk(db); |
|
|
|
|
|
|
|
RevCommit stashedIndex = stashedWorkTree.getParent(1); |
|
|
|
|
|
|
|
walk.parseBody(stashedIndex); |
|
|
|
|
|
|
|
walk.parseBody(stashedIndex.getTree()); |
|
|
|
|
|
|
|
walk.parseBody(stashedIndex.getParent(0)); |
|
|
|
|
|
|
|
List<DiffEntry> workTreeStashAgainstWorkTree = diffWorkingAgainstHead(stashedWorkTree); |
|
|
|
|
|
|
|
assertEquals(1, workTreeStashAgainstWorkTree.size()); |
|
|
|
|
|
|
|
List<DiffEntry> workIndexAgainstWorkTree = diffIndexAgainstHead(stashedWorkTree); |
|
|
|
|
|
|
|
assertEquals(1, workIndexAgainstWorkTree.size()); |
|
|
|
|
|
|
|
List<DiffEntry> indexStashAgainstWorkTree = diffIndexAgainstWorking(stashedWorkTree); |
|
|
|
|
|
|
|
assertEquals(1, indexStashAgainstWorkTree.size()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void indexDelete() throws Exception { |
|
|
|
public void indexDelete() throws Exception { |
|
|
|
git.rm().addFilepattern("file.txt").call(); |
|
|
|
git.rm().addFilepattern("file.txt").call(); |
|
|
|