Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn2016-11-05 13:41:02 -0400
committerMatthias Sohn2016-12-12 16:57:09 -0500
commit5f95132e5c3a0422f53c8f886757a8f23ee7a8e6 (patch)
tree43c52cd1beef3573397e9b8e7f81def5e434d4cf /org.eclipse.egit.core.test/src
parent9d4940d100557d2cfcb10f9a7609fc39bbb959ac (diff)
downloadegit-5f95132e5c3a0422f53c8f886757a8f23ee7a8e6.tar.gz
egit-5f95132e5c3a0422f53c8f886757a8f23ee7a8e6.tar.xz
egit-5f95132e5c3a0422f53c8f886757a8f23ee7a8e6.zip
Make auto-staging of files being deleted configurable
- by default do not auto-stage files being deleted - add an option to enable auto-staging of deleted files for those who want the old behavior. Bug: 507018 Change-Id: I5c906dd4fb7295f0ac153ada9be7ee341d8f46c8 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.egit.core.test/src')
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/GitMoveDeleteHookTest.java27
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitSubscriberMergeContextTest.java7
2 files changed, 30 insertions, 4 deletions
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/GitMoveDeleteHookTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/GitMoveDeleteHookTest.java
index 354641c82..401343566 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/GitMoveDeleteHookTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/GitMoveDeleteHookTest.java
@@ -30,6 +30,8 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.egit.core.op.AddToIndexOperation;
import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.egit.core.test.TestProject;
@@ -51,11 +53,18 @@ import org.eclipse.jgit.util.SystemReader;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.junit.experimental.theories.DataPoints;
+import org.junit.experimental.theories.Theories;
+import org.junit.experimental.theories.Theory;
+import org.junit.runner.RunWith;
/**
* All sorts of interesting cases
*/
+@RunWith(Theories.class)
public class GitMoveDeleteHookTest {
+ @DataPoints
+ public static boolean[] autoStageDeletions = { true, false };
TestUtils testUtils = new TestUtils();
@@ -139,8 +148,13 @@ public class GitMoveDeleteHookTest {
return project;
}
- @Test
- public void testDeleteFile() throws Exception {
+ @Theory
+ public void testDeleteFile(boolean autoStageDelete) throws Exception {
+ IEclipsePreferences p = InstanceScope.INSTANCE
+ .getNode(Activator.getPluginId());
+ p.putBoolean(GitCorePreferences.core_autoStageDeletion,
+ autoStageDelete);
+
TestProject project = initRepoInsideProjectInsideWorkspace();
testUtils.addFileToProject(project.getProject(), "file.txt",
"some text");
@@ -168,8 +182,13 @@ public class GitMoveDeleteHookTest {
// Check index for the deleted file
dirCache.read();
- assertEquals(1, dirCache.getEntryCount());
- assertNull(dirCache.getEntry("file.txt"));
+ if (autoStageDelete) {
+ assertEquals(1, dirCache.getEntryCount());
+ assertNull(dirCache.getEntry("file.txt"));
+ } else {
+ assertEquals(2, dirCache.getEntryCount());
+ assertNotNull(dirCache.getEntry("file.txt"));
+ }
assertNotNull(dirCache.getEntry("file2.txt"));
// Actual file is deleted
assertFalse(file.exists());
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitSubscriberMergeContextTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitSubscriberMergeContextTest.java
index e2e8cc778..3f112e3f9 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitSubscriberMergeContextTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitSubscriberMergeContextTest.java
@@ -26,6 +26,10 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.egit.core.Activator;
+import org.eclipse.egit.core.GitCorePreferences;
import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.egit.core.test.TestRepository;
import org.eclipse.egit.core.test.TestUtils;
@@ -347,6 +351,9 @@ public class GitSubscriberMergeContextTest extends ModelTestCase {
@Test
public void mergeModelWithDeletedFileNoConflict() throws Exception {
+ IEclipsePreferences p = InstanceScope.INSTANCE
+ .getNode(Activator.getPluginId());
+ p.putBoolean(GitCorePreferences.core_autoStageDeletion, true);
File file1 = testRepo.createFile(iProject, "file1."
+ SAMPLE_FILE_EXTENSION);
File file2 = testRepo.createFile(iProject, "file2."

Back to the top