diff --git a/org.eclipse.jgit/.settings/.api_filters b/org.eclipse.jgit/.settings/.api_filters index a1e79e2d2..37351c04f 100644 --- a/org.eclipse.jgit/.settings/.api_filters +++ b/org.eclipse.jgit/.settings/.api_filters @@ -21,4 +21,18 @@ + + + + + + + + + + + + + + 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 2398f54b0..d8a0fc7f3 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 7622603de..31be94c71 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 c1535fa1f..6ce348c1b 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 80c729007..22c1abd7d 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 5c652be18..8ff274e10 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 3c3b2ebd9..6c5e73d05 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 109b2df5f..54b1ae331 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; @@ -65,40 +64,6 @@ import org.eclipse.jgit.util.FS.Attributes; */ 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 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 1e58245ea..df80567d5 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; } /**