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 ce235a722..862711571 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 b8ee1ec0b..fc8bb874f 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 { 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(