Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2019-05-08 14:45:50 +0000
committerMichael Keppler2019-05-12 14:01:28 +0000
commitd03c47ba5073afac339ef7df0fe29b7bbf4c2427 (patch)
tree39a1374923fb9fe8b190b8ecc8d3429336ea954b /org.eclipse.egit.ui.test
parentc2d0f943309d07b8a0513ea7aec32139582e249e (diff)
downloadegit-d03c47ba5073afac339ef7df0fe29b7bbf4c2427.tar.gz
egit-d03c47ba5073afac339ef7df0fe29b7bbf4c2427.tar.xz
egit-d03c47ba5073afac339ef7df0fe29b7bbf4c2427.zip
Handle delete-modify conflicts in staging view
Delete-modify conflicts could not be resolved in the staging view by removing the file. If a conflicting file has been removed from the working tree, make staging it in the staging view remove it from the index. Note that if the preference for "Automatically stage files being deleted" is switched *on*, then deleting the conflicting file in the working tree would remove it from the index already. But with that preference *off* the user had no real way to resolve such conflicts. (Sometimes, this could be worked around by first staging the conflict, then unstaging, then deleting the file, and then staging the deletion.) The solution in this change works, but still leaves some non-working commands in the context menu. There's no delete command in the context menu, and the "replace with" commands (ours/theirs/HEAD/index) don't do anything for the side that deleted the file. Fixing that is left for a future enhancement. Bug: 546869 Change-Id: I9594587f9445acf0a9972b01933bc5d453168f65 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.egit.ui.test')
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/stagview/StagingViewTest.java48
1 files changed, 48 insertions, 0 deletions
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/stagview/StagingViewTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/stagview/StagingViewTest.java
index 6ed7f0764e..186b283553 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/stagview/StagingViewTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/stagview/StagingViewTest.java
@@ -17,6 +17,9 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.egit.core.JobFamilies;
import org.eclipse.egit.ui.common.StagingViewTester;
import org.eclipse.egit.ui.test.CommitMessageUtil;
import org.eclipse.egit.ui.test.TestUtil;
@@ -107,6 +110,51 @@ public class StagingViewTest extends AbstractStagingViewTestCase {
.getShortMessage());
}
+ @Test
+ public void testDeleteModifyConflict() throws Exception {
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJ1)
+ .getFolder(FOLDER).getFile(FILE1);
+ try (Git git = new Git(repository)) {
+ git.checkout().setCreateBranch(true).setName("side").call();
+ assertTrue(file.exists());
+ file.delete(true, null);
+ assertFalse(file.exists());
+ git.rm().addFilepattern(FILE1_PATH).call();
+ TestUtil.joinJobs(JobFamilies.INDEX_DIFF_CACHE_UPDATE);
+ git.commit().setMessage("File deleted").call();
+ TestUtil.waitForJobs(50, 5000);
+
+ git.checkout().setName("master").call();
+ commitOneFileChange("on master");
+
+ git.merge().include(repository.findRef("side")).call();
+ }
+ assertEquals(RepositoryState.MERGING, repository.getRepositoryState());
+
+ StagingViewTester stagingView = StagingViewTester.openStagingView();
+ assertEquals("", stagingView.getCommitMessage());
+ stagingView.assertCommitEnabled(false);
+
+ assertTrue(file.exists());
+ file.delete(true, null);
+ assertFalse(file.exists());
+ TestUtil.joinJobs(JobFamilies.INDEX_DIFF_CACHE_UPDATE);
+
+ stagingView.stageFile(FILE1_PATH);
+ assertEquals(RepositoryState.MERGING_RESOLVED,
+ repository.getRepositoryState());
+ String expectedMessage = "Merge branch 'side'";
+ assertThat(stagingView.getCommitMessage(), startsWith(expectedMessage));
+
+ stagingView.commit();
+ assertEquals(RepositoryState.SAFE, repository.getRepositoryState());
+
+ assertEquals(expectedMessage,
+ TestUtil.getHeadCommit(repository).getShortMessage());
+
+ assertFalse(file.exists());
+ }
+
private StagingViewTester commitOneFileChange(String fileContent)
throws Exception {
return commitOneFileChange(fileContent, TestUtil.TESTAUTHOR,

Back to the top