diff options
author | Robin Rosenberg <robin.rosenberg@dewire.com> | 2013-04-11 02:06:54 -0400 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org <gerrit@eclipse.org> | 2013-04-11 02:06:54 -0400 |
commit | 4955301fac54d8c28a1c0c7bc60c88462588b0ff (patch) | |
tree | f0a781ec875f104ba75104b8fec873306af1716e /org.eclipse.jgit.test | |
parent | b5cbfa0146051568673c50e8efba90d782963856 (diff) | |
parent | 1bede91db21a03ffcaefb8fb31f7c9521b8b331b (diff) | |
download | jgit-4955301fac54d8c28a1c0c7bc60c88462588b0ff.tar.gz jgit-4955301fac54d8c28a1c0c7bc60c88462588b0ff.zip |
Merge "Consider working tree changes when stashing newly added files"
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StashCreateCommandTest.java | 32 |
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(); |