diff options
9 files changed, 42 insertions, 78 deletions
diff --git a/org.eclipse.jgit/.settings/.api_filters b/org.eclipse.jgit/.settings/.api_filters index a1e79e2d29..37351c04fd 100644 --- a/org.eclipse.jgit/.settings/.api_filters +++ b/org.eclipse.jgit/.settings/.api_filters @@ -21,4 +21,18 @@ </message_arguments> </filter> </resource> + <resource path="src/org/eclipse/jgit/util/FileUtil.java" type="org.eclipse.jgit.util.FileUtil"> + <filter id="338792546"> + <message_arguments> + <message_argument value="org.eclipse.jgit.util.FileUtil"/> + <message_argument value="createSymLink(File, String)"/> + </message_arguments> + </filter> + <filter id="338792546"> + <message_arguments> + <message_argument value="org.eclipse.jgit.util.FileUtil"/> + <message_argument value="readSymlink(File)"/> + </message_arguments> + </filter> + </resource> </component> diff --git a/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties b/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties index 2398f54b05..d8a0fc7f3f 100644 --- a/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties +++ b/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties @@ -241,7 +241,6 @@ errorInvalidProtocolWantedOldNewRef=error: invalid protocol: wanted 'old new ref errorListing=Error listing {0} errorOccurredDuringUnpackingOnTheRemoteEnd=error occurred during unpacking on the remote end: {0} errorReadingInfoRefs=error reading info/refs -errorSymlinksNotSupported=Symlinks are not supported with this OS/JRE exceptionCaughtDuringExecutionOfHook=Exception caught during execution of "{0}" hook. exceptionCaughtDuringExecutionOfAddCommand=Exception caught during execution of add command exceptionCaughtDuringExecutionOfArchiveCommand=Exception caught during execution of archive command @@ -465,7 +464,7 @@ peeledLineBeforeRef=Peeled line before ref. peerDidNotSupplyACompleteObjectGraph=peer did not supply a complete object graph personIdentEmailNonNull=E-mail address of PersonIdent must not be null. personIdentNameNonNull=Name of PersonIdent must not be null. -prefixRemote=remote: +prefixRemote=remote: problemWithResolvingPushRefSpecsLocally=Problem with resolving push ref specs locally: {0} progressMonUploading=Uploading {0} propertyIsAlreadyNonNull=Property is already non null diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java index 7622603de2..31be94c711 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java @@ -300,7 +300,6 @@ public class JGitText extends TranslationBundle { /***/ public String errorListing; /***/ public String errorOccurredDuringUnpackingOnTheRemoteEnd; /***/ public String errorReadingInfoRefs; - /***/ public String errorSymlinksNotSupported; /***/ public String exceptionCaughtDuringExecutionOfHook; /***/ public String exceptionCaughtDuringExecutionOfAddCommand; /***/ public String exceptionCaughtDuringExecutionOfArchiveCommand; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java index c1535fa1fb..6ce348c1be 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java @@ -67,7 +67,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import org.eclipse.jgit.api.errors.JGitInternalException; -import org.eclipse.jgit.errors.SymlinksNotSupportedException; import org.eclipse.jgit.internal.JGitText; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.Repository; @@ -623,8 +622,7 @@ public abstract class FS { * @since 3.0 */ public String readSymLink(File path) throws IOException { - throw new SymlinksNotSupportedException( - JGitText.get().errorSymlinksNotSupported); + return FileUtils.readSymLink(path); } /** @@ -707,8 +705,7 @@ public abstract class FS { * @since 3.0 */ public void createSymLink(File path, String target) throws IOException { - throw new SymlinksNotSupportedException( - JGitText.get().errorSymlinksNotSupported); + FileUtils.createSymLink(path, target); } /** diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java index 80c7290073..22c1abd7d9 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java @@ -295,16 +295,6 @@ public class FS_POSIX extends FS { // no action on POSIX } - @Override - public String readSymLink(File path) throws IOException { - return FileUtil.readSymlink(path); - } - - @Override - public void createSymLink(File path, String target) throws IOException { - FileUtil.createSymLink(path, target); - } - /** * @since 3.3 */ diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32.java index 5c652be18a..8ff274e109 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32.java @@ -168,7 +168,7 @@ public class FS_Win32 extends FS { try { tempFile = File.createTempFile("tempsymlinktarget", ""); //$NON-NLS-1$ //$NON-NLS-2$ File linkName = new File(tempFile.getParentFile(), "tempsymlink"); //$NON-NLS-1$ - FileUtil.createSymLink(linkName, tempFile.getPath()); + createSymLink(linkName, tempFile.getPath()); supportSymlinks = Boolean.TRUE; linkName.delete(); } catch (IOException | UnsupportedOperationException e) { @@ -233,16 +233,6 @@ public class FS_Win32 extends FS { FileUtil.setHidden(path, hidden); } - @Override - public String readSymLink(File path) throws IOException { - return FileUtil.readSymlink(path); - } - - @Override - public void createSymLink(File path, String target) throws IOException { - FileUtil.createSymLink(path, target); - } - /** * @since 3.3 */ diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32_Cygwin.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32_Cygwin.java index 3c3b2ebd97..6c5e73d051 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32_Cygwin.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32_Cygwin.java @@ -218,16 +218,6 @@ public class FS_Win32_Cygwin extends FS_Win32 { FileUtil.setHidden(path, hidden); } - @Override - public String readSymLink(File path) throws IOException { - return FileUtil.readSymlink(path); - } - - @Override - public void createSymLink(File path, String target) throws IOException { - FileUtil.createSymLink(path, target); - } - /** * @since 3.3 */ diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtil.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtil.java index 109b2df5f2..54b1ae3319 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtil.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtil.java @@ -55,7 +55,6 @@ import java.nio.file.attribute.PosixFileAttributeView; import java.nio.file.attribute.PosixFileAttributes; import java.nio.file.attribute.PosixFilePermission; import java.text.Normalizer; -import java.text.Normalizer.Form; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.util.FS.Attributes; @@ -67,40 +66,6 @@ public class FileUtil { /** * @param path - * @return target path of the symlink - * @throws IOException - */ - public static String readSymlink(File path) throws IOException { - Path nioPath = path.toPath(); - Path target = Files.readSymbolicLink(nioPath); - String targetString = target.toString(); - if (SystemReader.getInstance().isWindows()) - targetString = targetString.replace('\\', '/'); - else if (SystemReader.getInstance().isMacOS()) - targetString = Normalizer.normalize(targetString, Form.NFC); - return targetString; - } - - /** - * @param path - * path of the symlink to be created - * @param target - * target of the symlink to be created - * @throws IOException - */ - public static void createSymLink(File path, String target) - throws IOException { - Path nioPath = path.toPath(); - if (Files.exists(nioPath, LinkOption.NOFOLLOW_LINKS)) - Files.delete(nioPath); - if (SystemReader.getInstance().isWindows()) - target = target.replace('/', '\\'); - Path nioTarget = new File(target).toPath(); - Files.createSymbolicLink(nioPath, nioTarget); - } - - /** - * @param path * @return {@code true} if the passed path is a symlink */ public static boolean isSymlink(File path) { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtils.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtils.java index 1e58245ea7..df80567d50 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtils.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtils.java @@ -48,7 +48,12 @@ package org.eclipse.jgit.util; import java.io.File; import java.io.IOException; import java.nio.channels.FileLock; +import java.nio.file.Files; +import java.nio.file.LinkOption; +import java.nio.file.Path; import java.text.MessageFormat; +import java.text.Normalizer; +import java.text.Normalizer.Form; import java.util.ArrayList; import java.util.List; import java.util.regex.Pattern; @@ -350,18 +355,33 @@ public class FileUtils { */ public static void createSymLink(File path, String target) throws IOException { - FS.DETECTED.createSymLink(path, target); + Path nioPath = path.toPath(); + if (Files.exists(nioPath, LinkOption.NOFOLLOW_LINKS)) { + Files.delete(nioPath); + } + if (SystemReader.getInstance().isWindows()) { + target = target.replace('/', '\\'); + } + Path nioTarget = new File(target).toPath(); + Files.createSymbolicLink(nioPath, nioTarget); } /** * @param path - * @return the target of the symbolic link, or null if it is not a symbolic - * link + * @return target path of the symlink, or null if it is not a symbolic link * @throws IOException * @since 3.0 */ public static String readSymLink(File path) throws IOException { - return FS.DETECTED.readSymLink(path); + Path nioPath = path.toPath(); + Path target = Files.readSymbolicLink(nioPath); + String targetString = target.toString(); + if (SystemReader.getInstance().isWindows()) { + targetString = targetString.replace('\\', '/'); + } else if (SystemReader.getInstance().isMacOS()) { + targetString = Normalizer.normalize(targetString, Form.NFC); + } + return targetString; } /** |