\r
#### fixes\r
\r
+- Fixed absolute path/canonical path discrepancy between Gitblit and JGit regarding use of symlinks (issue 78)\r
+\r
+**0.9.1** *released 2012-03-27*\r
+\r
+#### fixes\r
+\r
- Lucene folder was stored in working copy instead of in .git folder\r
\r
**0.9.0** *released 2012-03-27*\r
\r
import com.gitblit.models.RepositoryModel;\r
import com.gitblit.models.UserModel;\r
+import com.gitblit.utils.FileUtils;\r
import com.gitblit.utils.HttpUtils;\r
import com.gitblit.utils.StringUtils;\r
\r
*/\r
protected RepositoryModel getRepositoryModel(ReceivePack rp) {\r
Repository repository = rp.getRepository();\r
- String rootPath = GitBlit.getRepositoriesFolder().getAbsolutePath();\r
- String repositoryName = StringUtils.getRelativePath(rootPath, repository.getDirectory()\r
- .getAbsolutePath());\r
+ String repositoryName = FileUtils.getRelativePath(GitBlit.getRepositoriesFolder(), repository.getDirectory());\r
RepositoryModel model = GitBlit.self().getRepositoryModel(repositoryName);\r
return model;\r
}\r
}\r
}\r
}\r
+ \r
+ /**\r
+ * Determine the relative path between two files. Takes into account\r
+ * canonical paths, if possible.\r
+ * \r
+ * @param basePath\r
+ * @param path\r
+ * @return a relative path from basePath to path\r
+ */\r
+ public static String getRelativePath(File basePath, File path) {\r
+ File exactBase = getExactFile(basePath);\r
+ File exactPath = getExactFile(path);\r
+ return StringUtils.getRelativePath(exactBase.getPath(), exactPath.getPath());\r
+ }\r
+ \r
+ /**\r
+ * Returns the exact path for a file. This path will be the canonical path\r
+ * unless an exception is thrown in which case it will be the absolute path.\r
+ * \r
+ * @param path\r
+ * @return the exact file\r
+ */\r
+ public static File getExactFile(File path) {\r
+ try {\r
+ return path.getCanonicalFile();\r
+ } catch (IOException e) {\r
+ return path.getAbsoluteFile();\r
+ }\r
+ }\r
}\r
*/\r
private static List<String> getRepositoryList(String basePath, File searchFolder,\r
boolean onlyBare, boolean searchSubfolders) {\r
+ File baseFile = new File(basePath);\r
List<String> list = new ArrayList<String>();\r
for (File file : searchFolder.listFiles()) {\r
if (file.isDirectory()) {\r
continue;\r
}\r
// determine repository name relative to base path\r
- String repository = StringUtils.getRelativePath(basePath,\r
- file.getAbsolutePath());\r
+ String repository = FileUtils.getRelativePath(baseFile, file);\r
list.add(repository);\r
} else if (searchSubfolders && file.canRead()) {\r
// look for repositories in subfolders\r
import com.gitblit.models.IssueModel.Priority;\r
import com.gitblit.models.IssueModel.Status;\r
import com.gitblit.models.SearchResult;\r
+import com.gitblit.utils.FileUtils;\r
import com.gitblit.utils.IssueUtils;\r
import com.gitblit.utils.IssueUtils.IssueFilter;\r
-import com.gitblit.utils.StringUtils;\r
\r
/**\r
* Tests the mechanics of distributed issue management on the gb-issues branch.\r
@Test\r
public void testLifecycle() throws Exception {\r
Repository repository = GitBlitSuite.getIssuesTestRepository();\r
- String name = StringUtils.getRelativePath(GitBlitSuite.REPOSITORIES.getAbsolutePath(),\r
- repository.getDirectory().getAbsolutePath());\r
+ String name = FileUtils.getRelativePath(GitBlitSuite.REPOSITORIES, repository.getDirectory());\r
\r
// create and insert an issue\r
Change c1 = newChange("testCreation() " + Long.toHexString(System.currentTimeMillis()));\r
import org.eclipse.jgit.lib.Repository;\r
import org.junit.Test;\r
\r
+import com.gitblit.GitBlit;\r
import com.gitblit.LuceneExecutor;\r
import com.gitblit.models.RefModel;\r
import com.gitblit.models.RepositoryModel;\r
import com.gitblit.models.SearchResult;\r
+import com.gitblit.utils.FileUtils;\r
import com.gitblit.utils.JGitUtils;\r
import com.gitblit.utils.StringUtils;\r
\r
\r
private RepositoryModel newRepositoryModel(Repository repository) { \r
RepositoryModel model = new RepositoryModel();\r
- model.name = StringUtils.getRelativePath(GitBlitSuite.REPOSITORIES.getAbsolutePath(),\r
- repository.getDirectory().getAbsolutePath());\r
+ model.name = FileUtils.getRelativePath(GitBlitSuite.REPOSITORIES, repository.getDirectory());\r
model.hasCommits = JGitUtils.hasCommits(repository);\r
\r
// index all local branches\r