diff options
author | James Moger <james.moger@gitblit.com> | 2012-08-01 21:28:47 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2012-08-01 21:28:47 -0400 |
commit | d65fb8f1b77a7254c22edc9e7d8f47b29ec33072 (patch) | |
tree | f7e9852b36c7161022dd4dcd2ac778ac57ced10a /src/com | |
parent | 0adceb4b64dfe0dd509da33c6d733a47fbf803a2 (diff) | |
download | gitblit-d65fb8f1b77a7254c22edc9e7d8f47b29ec33072.tar.gz gitblit-d65fb8f1b77a7254c22edc9e7d8f47b29ec33072.zip |
Tweak to relative path determination for symlinks (issue 116)
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/gitblit/utils/FileUtils.java | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/com/gitblit/utils/FileUtils.java b/src/com/gitblit/utils/FileUtils.java index c291da6a..cba88d0c 100644 --- a/src/com/gitblit/utils/FileUtils.java +++ b/src/com/gitblit/utils/FileUtils.java @@ -226,7 +226,10 @@ public class FileUtils { public static String getRelativePath(File basePath, File path) {
File exactBase = getExactFile(basePath);
File exactPath = getExactFile(path);
- if (exactPath.getPath().startsWith(exactBase.getPath())) {
+ if (path.getAbsolutePath().startsWith(basePath.getAbsolutePath())) {
+ // absolute base-path match
+ return StringUtils.getRelativePath(basePath.getAbsolutePath(), path.getAbsolutePath());
+ } else if (exactPath.getPath().startsWith(exactBase.getPath())) {
// canonical base-path match
return StringUtils.getRelativePath(exactBase.getPath(), exactPath.getPath());
} else if (exactPath.getPath().startsWith(basePath.getAbsolutePath())) {
@@ -235,9 +238,6 @@ public class FileUtils { } else if (path.getAbsolutePath().startsWith(exactBase.getPath())) {
// mixed path match
return StringUtils.getRelativePath(exactBase.getPath(), path.getAbsolutePath());
- } else if (path.getAbsolutePath().startsWith(basePath.getAbsolutePath())) {
- // absolute base-path match
- return StringUtils.getRelativePath(basePath.getAbsolutePath(), path.getAbsolutePath());
}
// no relative relationship
return null;
|