Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Loskutov2015-09-13 17:19:51 +0000
committerAndrey Loskutov2015-09-13 17:19:51 +0000
commitfbb66bdb00b81fc817d9ecd4eed70d4e7d2b4a3e (patch)
tree0fd59f9e697a48dcdddbcbef63eed7da08bcda48
parent56529a0c680910d78ab672f630aabad3226879ab (diff)
downloadegit-fbb66bdb00b81fc817d9ecd4eed70d4e7d2b4a3e.tar.gz
egit-fbb66bdb00b81fc817d9ecd4eed70d4e7d2b4a3e.tar.xz
egit-fbb66bdb00b81fc817d9ecd4eed70d4e7d2b4a3e.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. Bug: 475453 Change-Id: I9ec19dc3cc31b4717db5a6348cb84a9d4e7751ae Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
-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, 46 insertions, 2 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 85fbafab6c..11a536b2d3 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;
@@ -23,6 +25,7 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
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;
@@ -36,6 +39,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.Assert;
import org.junit.Test;
@@ -74,6 +78,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 73b0a13514..6202f55a60 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
@@ -219,9 +219,13 @@ public class ConnectProviderOperation implements IEGitOperation {
@Nullable
private RepositoryMapping findActualRepository(
Collection<RepositoryMapping> repos, File suggestedRepo) {
- IPath path = Path.fromOSString(suggestedRepo.getPath());
+ File path = Path.fromOSString(suggestedRepo.getPath()).toFile();
for (RepositoryMapping rm : repos) {
- if (path.equals(rm.getGitDirAbsolutePath())) {
+ IPath other = rm.getGitDirAbsolutePath();
+ if (other == null) {
+ continue;
+ }
+ if (path.equals(other.toFile())) {
return rm;
}
}

Back to the top