Fix StashApplyCommand for stashes containing untracked changes.
If there are untracked changes, apply only the untracked tree after a successful merge. The merge tree from merging untracked with HEAD would also contain files already reset before (changes in tracked files) and try to reset those again,leading to false checkout conflicts. Bug: 505804 Change-Id: Iaced4d277623334d11e3d1cca5969590d7c5093e Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
This commit is contained in:
parent
d3148f9410
commit
46af7192a2
|
@ -736,4 +736,21 @@ public void untrackedFileConflictsWithWorkingDirectory()
|
|||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -232,20 +232,20 @@ public ObjectId call() throws GitAPIException,
|
|||
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(
|
||||
JGitText.get().stashApplyConflict);
|
||||
|
|
Loading…
Reference in New Issue