]> source.dussan.org Git - jgit.git/commitdiff
Fix broken symbolic links on Cygwin. 91/18691/2
authorJohn Ross <jwross@us.ibm.com>
Thu, 21 Nov 2013 19:48:42 +0000 (13:48 -0600)
committerMatthias Sohn <matthias.sohn@sap.com>
Mon, 2 Dec 2013 15:31:45 +0000 (16:31 +0100)
Bad files from symbolic links were being generated on Cygwin and
required resolution by the appropriate FS. Pass FS to getSymRef and call
FS.resolve before asking if the file is absolute.

Bug: 419494
Change-Id: I74aa7a285954cade77f41df6f813b6dafb5d6cd7
Signed-off-by: John Ross <jwross@us.ibm.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit/src/org/eclipse/jgit/lib/BaseRepositoryBuilder.java

index 28d90590a3a1f7df5c21048756f18a55bc81b22e..db622f319ddf97c79ef1bd9c325ba6b1a5b56e44 100644 (file)
@@ -100,7 +100,7 @@ public class BaseRepositoryBuilder<B extends BaseRepositoryBuilder, R extends Re
                                && ref[7] == ' ';
        }
 
-       private static File getSymRef(File workTree, File dotGit)
+       private static File getSymRef(File workTree, File dotGit, FS fs)
                        throws IOException {
                byte[] content = IO.readFully(dotGit);
                if (!isSymRef(content))
@@ -116,7 +116,7 @@ public class BaseRepositoryBuilder<B extends BaseRepositoryBuilder, R extends Re
                                        JGitText.get().invalidGitdirRef, dotGit.getAbsolutePath()));
 
                String gitdirPath = RawParseUtils.decode(content, pathStart, lineEnd);
-               File gitdirFile = new File(gitdirPath);
+               File gitdirFile = fs.resolve(workTree, gitdirPath);
                if (gitdirFile.isAbsolute())
                        return gitdirFile;
                else
@@ -516,7 +516,7 @@ public class BaseRepositoryBuilder<B extends BaseRepositoryBuilder, R extends Re
                                        break;
                                } else if (dir.isFile())
                                        try {
-                                               setGitDir(getSymRef(current, dir));
+                                               setGitDir(getSymRef(current, dir, tryFS));
                                                break;
                                        } catch (IOException ignored) {
                                                // Continue searching if gitdir ref isn't found
@@ -597,7 +597,7 @@ public class BaseRepositoryBuilder<B extends BaseRepositoryBuilder, R extends Re
                        if (!dotGit.isFile())
                                setGitDir(dotGit);
                        else
-                               setGitDir(getSymRef(getWorkTree(), dotGit));
+                               setGitDir(getSymRef(getWorkTree(), dotGit, safeFS()));
                }
        }