diff options
author | Thomas Wolf | 2019-05-17 21:07:46 +0000 |
---|---|---|
committer | Thomas Wolf | 2019-05-17 21:07:46 +0000 |
commit | 01b939fba59f2f6ec04663e84242e2c3cdc8f24c (patch) | |
tree | 42e74c27336ce5a34d257180a58ce4a06be7a7d0 /org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test | |
parent | ba0338dadf704ce24a63cd99a22e3acac7887509 (diff) | |
download | egit-01b939fba59f2f6ec04663e84242e2c3cdc8f24c.tar.gz egit-01b939fba59f2f6ec04663e84242e2c3cdc8f24c.tar.xz egit-01b939fba59f2f6ec04663e84242e2c3cdc8f24c.zip |
Fix resetting conflicting files on branch switch
The new code from commit 8a66893 inadvertently reset to the index
version instead of to HEAD and thus didn't reset staged changes.
Fix this and add a new test.
Change-Id: Icf6ffe38949cc8fd42cb35196c090a66c5527901
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test')
-rw-r--r-- | org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/BranchAndResetActionTest.java | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/BranchAndResetActionTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/BranchAndResetActionTest.java index 980ba7663d..33c4cc9b4c 100644 --- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/BranchAndResetActionTest.java +++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/BranchAndResetActionTest.java @@ -45,6 +45,7 @@ import org.eclipse.egit.ui.test.ContextMenuHelper; import org.eclipse.egit.ui.test.TestUtil; import org.eclipse.jface.bindings.keys.KeyStroke; import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jgit.api.Git; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Repository; @@ -129,8 +130,8 @@ public class BranchAndResetActionTest extends LocalRepositoryTestCase { } } - @Test - public void testCheckoutWithConflictsAndReset() throws Exception { + private void checkoutWithConflictsAndReset(boolean stage) + throws Exception { String charset = ResourcesPlugin.getWorkspace().getRoot() .getProject(PROJ1).getDefaultCharset(); String file1Content = getTestFileContent(); @@ -140,6 +141,11 @@ public class BranchAndResetActionTest extends LocalRepositoryTestCase { new ByteArrayInputStream( "New content".getBytes(charset)), IResource.NONE, null); + if (stage) { + try (Git git = new Git(lookupRepository(repositoryFile))) { + git.add().addFilepattern(FILE1_PATH).call(); + } + } String file2Content = "Also changed"; ResourcesPlugin.getWorkspace().getRoot().getProject(PROJ1) .getFolder(FOLDER).getFile(FILE2).setContents( @@ -163,6 +169,16 @@ public class BranchAndResetActionTest extends LocalRepositoryTestCase { } @Test + public void testCheckoutWithConflictsAndReset() throws Exception { + checkoutWithConflictsAndReset(false); + } + + @Test + public void testCheckoutWithStagedConflictsAndReset() throws Exception { + checkoutWithConflictsAndReset(true); + } + + @Test public void testCheckoutWithNonDeleted() throws Exception { // we need to check if this file system has problems to // delete a file with an open FileInputStrem |