Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Loskutov2015-09-13 13:19:51 -0400
committerMatthias Sohn2015-09-13 18:26:50 -0400
commite34dc6d99967ade4277556c766ba27f4e6d153d2 (patch)
treecf9fd8fb82698badba3f934de4ddf04b8ddbe48c
parent8711ef87dfabca84e5edd3b9fb5cbd364c160b39 (diff)
downloadegit-e34dc6d99967ade4277556c766ba27f4e6d153d2.tar.gz
egit-e34dc6d99967ade4277556c766ba27f4e6d153d2.tar.xz
egit-e34dc6d99967ade4277556c766ba27f4e6d153d2.zip
Don't use IPath.equals() since it is broken on Windows
C:\\test and c:\\test are different paths for IPath.equals(). So if we search for repositories, we cannot rely on it's implementation and should compare java.io.File instances instead. Cherry picked from commit fbb66bdb00b81fc817d9ecd4eed70d4e7d2b4a3e Bug: 475453 Change-Id: I87a57e02abb73f15e764653cf6b86774096c8e28 Signed-off-by: Andrey Loskutov <loskutov@gmx.de> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/ConnectProviderOperationTest.java40
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConnectProviderOperation.java8
2 files changed, 47 insertions, 1 deletions
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/ConnectProviderOperationTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/ConnectProviderOperationTest.java
index 1b67e5daf..7460917cb 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/ConnectProviderOperationTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/ConnectProviderOperationTest.java
@@ -10,7 +10,9 @@
*******************************************************************************/
package org.eclipse.egit.core.test.op;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@@ -22,6 +24,7 @@ import java.io.IOException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope;
@@ -35,6 +38,7 @@ import org.eclipse.egit.core.test.TestRepository;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
+import org.eclipse.jgit.util.FS;
import org.eclipse.team.core.RepositoryProvider;
import org.junit.Test;
@@ -67,6 +71,42 @@ public class ConnectProviderOperationTest extends GitTestCase {
}
@Test
+ public void testNewRepositoryCaseSensitive()
+ throws CoreException, IOException {
+ if (FS.detect().isCaseSensitive()) {
+ return;
+ }
+ Repository repository = FileRepositoryBuilder.create(gitDir);
+ repository.create();
+ repository.close();
+
+ IPath path = new Path(gitDir.toString());
+ String device = path.getDevice();
+ if (device == null) {
+ // not windows???
+ return;
+ }
+ if (!device.toLowerCase().equals(device)) {
+ path = path.setDevice(device.toLowerCase());
+ } else {
+ path = path.setDevice(device.toUpperCase());
+ }
+ assertNotEquals(path, new Path(gitDir.toString()));
+ assertNotEquals(path.toFile().toString(),
+ new Path(gitDir.toString()).toFile().toString());
+ assertEquals(path.toFile(), gitDir);
+
+ ConnectProviderOperation operation = new ConnectProviderOperation(
+ project.getProject(),
+ path.toFile());
+ operation.execute(null);
+
+ assertTrue(RepositoryProvider.isShared(project.getProject()));
+
+ assertTrue(gitDir.exists());
+ }
+
+ @Test
public void testAutoIgnoresDerivedFolder() throws Exception {
// enable auto-ignore
IEclipsePreferences p = InstanceScope.INSTANCE.getNode(Activator
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConnectProviderOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConnectProviderOperation.java
index 4c086d566..795c8874b 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConnectProviderOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConnectProviderOperation.java
@@ -212,9 +212,15 @@ public class ConnectProviderOperation implements IEGitOperation {
*/
private RepositoryMapping findActualRepository(
Collection<RepositoryMapping> repos, File suggestedRepo) {
+ File path = Path.fromOSString(suggestedRepo.getPath()).toFile();
for (RepositoryMapping rm : repos) {
- if (rm.getGitDirAbsolutePath().equals(Path.fromOSString(suggestedRepo.getPath())))
+ IPath other = rm.getGitDirAbsolutePath();
+ if (other == null) {
+ continue;
+ }
+ if (path.equals(other.toFile())) {
return rm;
+ }
}
return null;
}

Back to the top