Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2019-05-17 17:07:46 -0400
committerThomas Wolf2019-05-17 17:07:46 -0400
commit01b939fba59f2f6ec04663e84242e2c3cdc8f24c (patch)
tree42e74c27336ce5a34d257180a58ce4a06be7a7d0 /org.eclipse.egit.ui.test/src
parentba0338dadf704ce24a63cd99a22e3acac7887509 (diff)
downloadegit-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')
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/BranchAndResetActionTest.java20
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 980ba7663..33c4cc9b4 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

Back to the top