From 8f7776417e26311285ba62fbd7e203abc0e40975 Mon Sep 17 00:00:00 2001 From: Andrey Loskutov Date: Sun, 16 Aug 2015 10:21:33 +0200 Subject: [PATCH] Don't read link target for symlinks decoration to avoid exceptions The code is not needed, because File.isDirectory() works fine for links too, and an attempt to resolve a link if the actual file is a real file will be terminated with exception. Bug: 475063 Change-Id: I23dd6989aba65987a0a657749259ed2c766b9cc8 Signed-off-by: Andrey Loskutov --- .../src/org/eclipse/egit/ui/internal/UIText.java | 3 --- .../internal/staging/StagingViewLabelProvider.java | 22 +++++----------------- .../org/eclipse/egit/ui/internal/uitext.properties | 1 - 3 files changed, 5 insertions(+), 21 deletions(-) diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java index d927fbc96..3645877db 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java @@ -5137,9 +5137,6 @@ public class UIText extends NLS { public static String StagingViewContentProvider_SubmoduleError; /** */ - public static String StagingViewLabelProvider_SymlinkError; - - /** */ public static String StashApplyCommand_applyFailed; /** */ diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingViewLabelProvider.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingViewLabelProvider.java index 242a7087a..adc7887e4 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingViewLabelProvider.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingViewLabelProvider.java @@ -9,14 +9,12 @@ package org.eclipse.egit.ui.internal.staging; import java.io.File; -import java.io.IOException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; import org.eclipse.egit.ui.Activator; import org.eclipse.egit.ui.UIUtils; import org.eclipse.egit.ui.internal.UIIcons; -import org.eclipse.egit.ui.internal.UIText; import org.eclipse.egit.ui.internal.decorators.DecorationResult; import org.eclipse.egit.ui.internal.decorators.GitLightweightDecorator.DecorationHelper; import org.eclipse.egit.ui.internal.staging.StagingView.Presentation; @@ -28,7 +26,6 @@ import org.eclipse.jface.viewers.DecorationOverlayIcon; import org.eclipse.jface.viewers.IDecoration; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.StyledString; -import org.eclipse.jgit.util.FS; import org.eclipse.swt.graphics.Image; import org.eclipse.ui.ISharedImages; import org.eclipse.ui.PlatformUI; @@ -98,21 +95,12 @@ public class StagingViewLabelProvider extends LabelProvider { image = (Image) resourceManager.get(UIUtils.DEFAULT_FILE_IMG); } if (diff.isSymlink()) { - try { - IPath diffLocation = diff.getLocation(); - if (diffLocation != null) { - File diffFile = diffLocation.toFile(); - if (diffFile.exists()) { - String targetPath = FS.DETECTED.readSymLink(diffFile); - if (targetPath != null - && new File(diffFile, targetPath).isDirectory()) { - image = FOLDER; - } - } + IPath diffLocation = diff.getLocation(); + if (diffLocation != null) { + File diffFile = diffLocation.toFile(); + if (diffFile.isDirectory()) { + image = FOLDER; } - } catch (IOException e) { - Activator - .error(UIText.StagingViewLabelProvider_SymlinkError, e); } image = addSymlinkDecorationToImage(image); } diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties index abef0d6f0..f4aab07f7 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties @@ -1789,7 +1789,6 @@ StagingView_RemoveJob=Removing files from index... StagingView_ResetJob=Unstaging files... StagingViewContentProvider_SubmoduleError=Unhandled exception while analyzing submodules -StagingViewLabelProvider_SymlinkError=Unhandled exception while checking symlink target StashApplyCommand_applyFailed=Applying stashed commit ''{0}'' failed due to ''{1}'' StashApplyCommand_jobTitle=Apply changes from stashed commit ''{0}'' StashCreateCommand_includeUntrackedLabel=Include untracked files -- 2.11.4.GIT