diff options
author | Christian Halstrick <christian.halstrick@sap.com> | 2017-01-16 03:44:57 -0500 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org <gerrit@eclipse.org> | 2017-01-16 03:45:00 -0500 |
commit | 8a46b603711145a05e5cd59010bc07c6f36dde41 (patch) | |
tree | 807cf6e51c5b653b9939880f40746a0f253d192a | |
parent | 1c4b3f8c45fe2bbcc0ea6aa9ffee107312b37310 (diff) | |
parent | 46af7192a20bb9d2daf72badc3521320795d44a9 (diff) | |
download | jgit-8a46b603711145a05e5cd59010bc07c6f36dde41.tar.gz jgit-8a46b603711145a05e5cd59010bc07c6f36dde41.zip |
Merge "Fix StashApplyCommand for stashes containing untracked changes."
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StashApplyCommandTest.java | 17 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/api/StashApplyCommand.java | 10 |
2 files changed, 22 insertions, 5 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StashApplyCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StashApplyCommandTest.java index ce235a722f..862711571c 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StashApplyCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StashApplyCommandTest.java @@ -736,4 +736,21 @@ public class StashApplyCommandTest extends RepositoryTestCase { } assertEquals("working-directory", read(path)); } + + @Test + public void untrackedAndTrackedChanges() throws Exception { + writeTrashFile(PATH, "changed"); + String path = "untracked.txt"; + writeTrashFile(path, "untracked"); + git.stashCreate().setIncludeUntracked(true).call(); + assertTrue(PATH + " should exist", check(PATH)); + assertEquals(PATH + " should have been reset", "content", read(PATH)); + assertFalse(path + " should not exist", check(path)); + git.stashApply().setStashRef("stash@{0}").call(); + assertTrue(PATH + " should exist", check(PATH)); + assertEquals(PATH + " should have new content", "changed", read(PATH)); + assertTrue(path + " should exist", check(path)); + assertEquals(path + " should have new content", "untracked", + read(path)); + } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/StashApplyCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/StashApplyCommand.java index b8ee1ec0b3..fc8bb874fb 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/StashApplyCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/StashApplyCommand.java @@ -232,19 +232,19 @@ public class StashApplyCommand extends GitCommand<ObjectId> { untrackedMerger.setBase(null); boolean ok = untrackedMerger.merge(headCommit, untrackedCommit); - if (ok) + if (ok) { try { RevTree untrackedTree = revWalk - .parseTree(untrackedMerger - .getResultTreeId()); + .parseTree(untrackedCommit); resetUntracked(untrackedTree); } catch (CheckoutConflictException e) { throw new StashApplyFailureException( - JGitText.get().stashApplyConflict); + JGitText.get().stashApplyConflict, e); } - else + } else { throw new StashApplyFailureException( JGitText.get().stashApplyConflict); + } } } else { throw new StashApplyFailureException( |