]> source.dussan.org Git - gitblit.git/commitdiff
Tweak to relative path determination for symlinks (issue 116)
authorJames Moger <james.moger@gitblit.com>
Thu, 2 Aug 2012 01:28:47 +0000 (21:28 -0400)
committerJames Moger <james.moger@gitblit.com>
Thu, 2 Aug 2012 01:28:47 +0000 (21:28 -0400)
src/com/gitblit/utils/FileUtils.java

index c291da6a347d8a32c158caf2689a8a086950e876..cba88d0ca74ce23c63165b379a9b3c1e04c017d8 100644 (file)
@@ -226,7 +226,10 @@ public class FileUtils {
        public static String getRelativePath(File basePath, File path) {\r
                File exactBase = getExactFile(basePath);\r
                File exactPath = getExactFile(path);\r
-               if (exactPath.getPath().startsWith(exactBase.getPath())) {\r
+               if (path.getAbsolutePath().startsWith(basePath.getAbsolutePath())) {\r
+                       // absolute base-path match\r
+                       return StringUtils.getRelativePath(basePath.getAbsolutePath(), path.getAbsolutePath());\r
+               } else if (exactPath.getPath().startsWith(exactBase.getPath())) {\r
                        // canonical base-path match\r
                        return StringUtils.getRelativePath(exactBase.getPath(), exactPath.getPath());\r
                } else if (exactPath.getPath().startsWith(basePath.getAbsolutePath())) {\r
@@ -235,9 +238,6 @@ public class FileUtils {
                } else if (path.getAbsolutePath().startsWith(exactBase.getPath())) {\r
                        // mixed path match\r
                        return StringUtils.getRelativePath(exactBase.getPath(), path.getAbsolutePath());\r
-               } else if (path.getAbsolutePath().startsWith(basePath.getAbsolutePath())) {\r
-                       // absolute base-path match\r
-                       return StringUtils.getRelativePath(basePath.getAbsolutePath(), path.getAbsolutePath());\r
                }\r
                // no relative relationship\r
                return null;\r