Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestRepository.java12
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/RepositoryCache.java18
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/RepositoryUtil.java18
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/internal/util/ProjectUtil.java20
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryMapping.java6
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/share/SharingWizardTest.java8
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositorySearchDialog.java27
7 files changed, 29 insertions, 80 deletions
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestRepository.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestRepository.java
index 9c7e3bb083..7be77c529b 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestRepository.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestRepository.java
@@ -78,11 +78,7 @@ public class TestRepository {
tmpRepository.close();
// use repository instance from RepositoryCache!
repository = Activator.getDefault().getRepositoryCache().lookupRepository(gitDir);
- try {
- workdirPrefix = repository.getWorkTree().getCanonicalPath();
- } catch (IOException err) {
- workdirPrefix = repository.getWorkTree().getAbsolutePath();
- }
+ workdirPrefix = repository.getWorkTree().getAbsolutePath();
workdirPrefix = workdirPrefix.replace('\\', '/');
if (!workdirPrefix.endsWith("/")) //$NON-NLS-1$
workdirPrefix += "/"; //$NON-NLS-1$
@@ -96,11 +92,7 @@ public class TestRepository {
*/
public TestRepository(Repository repository) throws IOException {
this.repository = repository;
- try {
- workdirPrefix = repository.getWorkTree().getCanonicalPath();
- } catch (IOException err) {
- workdirPrefix = repository.getWorkTree().getAbsolutePath();
- }
+ workdirPrefix = repository.getWorkTree().getAbsolutePath();
workdirPrefix = workdirPrefix.replace('\\', '/');
if (!workdirPrefix.endsWith("/")) //$NON-NLS-1$
workdirPrefix += "/"; //$NON-NLS-1$
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/RepositoryCache.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/RepositoryCache.java
index 05e7894009..161c02272e 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/RepositoryCache.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/RepositoryCache.java
@@ -106,19 +106,13 @@ public class RepositoryCache {
int largestSegmentCount = 0;
for (Repository r : repositories) {
if (!r.isBare()) {
- try {
- IPath repoPath = new Path(r.getWorkTree()
- .getCanonicalPath());
- if (location != null && repoPath.isPrefixOf(location)) {
- if (repository == null
- || repoPath.segmentCount() > largestSegmentCount) {
- repository = r;
- largestSegmentCount = repoPath.segmentCount();
- }
+ IPath repoPath = new Path(r.getWorkTree().getAbsolutePath());
+ if (location != null && repoPath.isPrefixOf(location)) {
+ if (repository == null
+ || repoPath.segmentCount() > largestSegmentCount) {
+ repository = r;
+ largestSegmentCount = repoPath.segmentCount();
}
- } catch (IOException e) {
- Activator
- .error("looking up working tree path of git repository failed", e); //$NON-NLS-1$
}
}
}
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/RepositoryUtil.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/RepositoryUtil.java
index a017f7c11d..53c612c45d 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/RepositoryUtil.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/RepositoryUtil.java
@@ -328,14 +328,6 @@ public class RepositoryUtil {
return repos;
}
- private String getPath(File repositoryDir) {
- try {
- return repositoryDir.getCanonicalPath();
- } catch (IOException e) {
- return repositoryDir.getAbsolutePath();
- }
- }
-
/**
*
* @param repositoryDir
@@ -353,7 +345,7 @@ public class RepositoryUtil {
CoreText.RepositoryUtil_DirectoryIsNotGitDirectory,
repositoryDir));
- String dirString = getPath(repositoryDir);
+ String dirString = repositoryDir.getAbsolutePath();
List<String> dirStrings = getConfiguredRepositories();
if (dirStrings.contains(dirString)) {
@@ -374,12 +366,10 @@ public class RepositoryUtil {
*/
public boolean removeDir(File file) {
synchronized (prefs) {
-
- String dir = getPath(file);
-
+ String dirString = file.getAbsolutePath();
Set<String> dirStrings = new HashSet<String>();
dirStrings.addAll(getConfiguredRepositories());
- if (dirStrings.remove(dir)) {
+ if (dirStrings.remove(dirString)) {
saveDirs(dirStrings);
return true;
}
@@ -412,7 +402,7 @@ public class RepositoryUtil {
* @return true if contains repository, false otherwise
*/
public boolean contains(final Repository repository) {
- return contains(getPath(repository.getDirectory()));
+ return contains(repository.getDirectory().getAbsolutePath());
}
/**
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/util/ProjectUtil.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/util/ProjectUtil.java
index 7093288f30..706b63e664 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/util/ProjectUtil.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/util/ProjectUtil.java
@@ -35,7 +35,6 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.egit.core.Activator;
import org.eclipse.egit.core.internal.CoreText;
import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.jgit.lib.Constants;
@@ -458,11 +457,7 @@ public class ProjectUtil {
// Initialize recursion guard for recursive symbolic links
if (visistedDirs == null) {
directoriesVisited = new HashSet<String>();
- try {
- directoriesVisited.add(directory.getCanonicalPath());
- } catch (IOException exception) {
- Activator.logError(exception.getLocalizedMessage(), exception);
- }
+ directoriesVisited.add(directory.getAbsolutePath());
} else
directoriesVisited = visistedDirs;
@@ -486,15 +481,10 @@ public class ProjectUtil {
// Skip .metadata folders
if (contents[i].getName().equals(METADATA_FOLDER))
continue;
- try {
- String canonicalPath = contents[i].getCanonicalPath();
- if (!directoriesVisited.add(canonicalPath))
- // already been here --> do not recurse
- continue;
- } catch (IOException exception) {
- Activator.logError(exception.getLocalizedMessage(), exception);
-
- }
+ String path = contents[i].getAbsolutePath();
+ if (!directoriesVisited.add(path))
+ // already been here --> do not recurse
+ continue;
findProjectFiles(files, contents[i], searchNested,
directoriesVisited, pm);
}
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryMapping.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryMapping.java
index dbafbe1b1f..699a31f7fb 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryMapping.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryMapping.java
@@ -196,11 +196,7 @@ public class RepositoryMapping {
synchronized void setRepository(final Repository r) {
db = r;
- try {
- workdirPrefix = getWorkTree().getCanonicalPath();
- } catch (IOException err) {
- workdirPrefix = getWorkTree().getAbsolutePath();
- }
+ workdirPrefix = getWorkTree().getAbsolutePath();
workdirPrefix = workdirPrefix.replace('\\', '/');
if (!workdirPrefix.endsWith("/")) //$NON-NLS-1$
workdirPrefix += "/"; //$NON-NLS-1$
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/share/SharingWizardTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/share/SharingWizardTest.java
index c8cdb0a5bf..32cb71f4ca 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/share/SharingWizardTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/share/SharingWizardTest.java
@@ -133,7 +133,7 @@ public class SharingWizardTest extends LocalRepositoryTestCase {
if (!(gitDirParent.toString() + File.separator)
.startsWith(workspacePath.toString() + File.separator))
if (!(gitDirParent.toString() + File.separator)
- .startsWith(getTestDirectory().getCanonicalPath()
+ .startsWith(getTestDirectory().getAbsolutePath()
.toString() + File.separator))
fail("Attempting cleanup of directory neither in workspace nor test directory"
+ canonicalFile);
@@ -197,7 +197,7 @@ public class SharingWizardTest extends LocalRepositoryTestCase {
public void shareProjectWithAlreadyCreatedRepos() throws IOException,
InterruptedException, JGitInternalException, GitAPIException {
Repository repo1 = FileRepositoryBuilder.create(new File(
- createProject(projectName1), "../.git"));
+ new File(createProject(projectName1)).getParent(), ".git"));
repo1.create();
repo1.close();
Repository repo2 = FileRepositoryBuilder.create(new File(
@@ -242,10 +242,10 @@ public class SharingWizardTest extends LocalRepositoryTestCase {
existingOrNewPage.assertEnabling(false, false, true);
bot.button("Finish").click();
Thread.sleep(1000);
- assertEquals(repo1.getDirectory().getCanonicalPath(), RepositoryMapping
+ assertEquals(repo1.getDirectory().getAbsolutePath(), RepositoryMapping
.getMapping(workspace.getRoot().getProject(projectName1))
.getRepository().getDirectory().toString());
- assertEquals(repo2.getDirectory().getCanonicalPath(), RepositoryMapping
+ assertEquals(repo2.getDirectory().getAbsolutePath(), RepositoryMapping
.getMapping(workspace.getRoot().getProject(projectName2))
.getRepository().getDirectory().toString());
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositorySearchDialog.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositorySearchDialog.java
index 4bb37b5efb..8fbb536c39 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositorySearchDialog.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositorySearchDialog.java
@@ -11,7 +11,6 @@
package org.eclipse.egit.ui.internal.repository;
import java.io.File;
-import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Collection;
import java.util.HashSet;
@@ -408,22 +407,14 @@ public class RepositorySearchDialog extends WizardPage {
continue;
if (FileKey.isGitRepository(child, FS.DETECTED)) {
- try {
- strings.add(child.getCanonicalPath());
- } catch (IOException e) {
- // ignore here
- }
+ strings.add(child.getAbsolutePath());
monitor.setTaskName(NLS
.bind(UIText.RepositorySearchDialog_RepositoriesFound_message,
Integer.valueOf(strings.size())));
} else if (FileKey.isGitRepository(new File(child,
Constants.DOT_GIT), FS.DETECTED)) {
- try {
- strings.add(new File(child, Constants.DOT_GIT)
- .getCanonicalPath());
- } catch (IOException e) {
- // ignore here
- }
+ strings.add(new File(child, Constants.DOT_GIT)
+ .getAbsolutePath());
monitor.setTaskName(NLS
.bind(UIText.RepositorySearchDialog_RepositoriesFound_message,
Integer.valueOf(strings.size())));
@@ -452,15 +443,11 @@ public class RepositorySearchDialog extends WizardPage {
if(!file.exists())
return;
+ prefs.put(PREF_PATH, file.getAbsolutePath());
try {
- prefs.put(PREF_PATH, file.getCanonicalPath());
- try {
- prefs.flush();
- } catch (BackingStoreException e1) {
- // ignore here
- }
- } catch (IOException e2) {
- // ignore
+ prefs.flush();
+ } catch (BackingStoreException e1) {
+ // ignore here
}
final TreeSet<String> validDirs = new TreeSet<String>(getCheckedItems());

Back to the top