From 65f55e2a2cdbce33ed4d2d7111b49ff00b2fd575 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Mon, 06 Aug 2012 17:39:25 -0400
Subject: [PATCH] Drop failed attempt to add user or team (issue 118)
---
src/com/gitblit/utils/FileUtils.java | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/src/com/gitblit/utils/FileUtils.java b/src/com/gitblit/utils/FileUtils.java
index a14928f..cba88d0 100644
--- a/src/com/gitblit/utils/FileUtils.java
+++ b/src/com/gitblit/utils/FileUtils.java
@@ -226,7 +226,21 @@
public static String getRelativePath(File basePath, File path) {
File exactBase = getExactFile(basePath);
File exactPath = getExactFile(path);
- return StringUtils.getRelativePath(exactBase.getPath(), exactPath.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())) {
+ // mixed path match
+ return StringUtils.getRelativePath(basePath.getAbsolutePath(), exactPath.getPath());
+ } else if (path.getAbsolutePath().startsWith(exactBase.getPath())) {
+ // mixed path match
+ return StringUtils.getRelativePath(exactBase.getPath(), path.getAbsolutePath());
+ }
+ // no relative relationship
+ return null;
}
/**
--
Gitblit v1.9.1