aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst
diff options
context:
space:
mode:
authorRobin Rosenberg <robin.rosenberg@dewire.com>2013-04-09 21:22:18 +0200
committerRobin Rosenberg <robin.rosenberg@dewire.com>2013-04-09 21:28:15 +0200
commit1bede91db21a03ffcaefb8fb31f7c9521b8b331b (patch)
tree2d3279c23639068ac4c6cc1673447375ace39801 /org.eclipse.jgit.test/tst
parent59baf9148e4b16028203d9e881136ab4c005202c (diff)
downloadjgit-1bede91db21a03ffcaefb8fb31f7c9521b8b331b.tar.gz
jgit-1bede91db21a03ffcaefb8fb31f7c9521b8b331b.zip
Consider working tree changes when stashing newly added files
Bug: 402396 Change-Id: I50ff707c0c9abcab3f98eea21aaa6e824f7af63a
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StashCreateCommandTest.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StashCreateCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StashCreateCommandTest.java
index f7eba5814f..544d591fe9 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StashCreateCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StashCreateCommandTest.java
@@ -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
public void noLocalChanges() throws Exception {
assertNull(git.stashCreate().call());
@@ -195,6 +207,26 @@ public class StashCreateCommandTest extends RepositoryTestCase {
}
@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
public void indexDelete() throws Exception {
git.rm().addFilepattern("file.txt").call();