Fix broken symbolic links on Cygwin.
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>
This commit is contained in:
parent
591998c2d6
commit
99608f0b9a
|
@ -100,7 +100,7 @@ private static boolean isSymRef(byte[] ref) {
|
||||||
&& ref[7] == ' ';
|
&& ref[7] == ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
private static File getSymRef(File workTree, File dotGit)
|
private static File getSymRef(File workTree, File dotGit, FS fs)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
byte[] content = IO.readFully(dotGit);
|
byte[] content = IO.readFully(dotGit);
|
||||||
if (!isSymRef(content))
|
if (!isSymRef(content))
|
||||||
|
@ -116,7 +116,7 @@ private static File getSymRef(File workTree, File dotGit)
|
||||||
JGitText.get().invalidGitdirRef, dotGit.getAbsolutePath()));
|
JGitText.get().invalidGitdirRef, dotGit.getAbsolutePath()));
|
||||||
|
|
||||||
String gitdirPath = RawParseUtils.decode(content, pathStart, lineEnd);
|
String gitdirPath = RawParseUtils.decode(content, pathStart, lineEnd);
|
||||||
File gitdirFile = new File(gitdirPath);
|
File gitdirFile = fs.resolve(workTree, gitdirPath);
|
||||||
if (gitdirFile.isAbsolute())
|
if (gitdirFile.isAbsolute())
|
||||||
return gitdirFile;
|
return gitdirFile;
|
||||||
else
|
else
|
||||||
|
@ -516,7 +516,7 @@ public B findGitDir(File current) {
|
||||||
break;
|
break;
|
||||||
} else if (dir.isFile())
|
} else if (dir.isFile())
|
||||||
try {
|
try {
|
||||||
setGitDir(getSymRef(current, dir));
|
setGitDir(getSymRef(current, dir, tryFS));
|
||||||
break;
|
break;
|
||||||
} catch (IOException ignored) {
|
} catch (IOException ignored) {
|
||||||
// Continue searching if gitdir ref isn't found
|
// Continue searching if gitdir ref isn't found
|
||||||
|
@ -597,7 +597,7 @@ protected void setupGitDir() throws IOException {
|
||||||
if (!dotGit.isFile())
|
if (!dotGit.isFile())
|
||||||
setGitDir(dotGit);
|
setGitDir(dotGit);
|
||||||
else
|
else
|
||||||
setGitDir(getSymRef(getWorkTree(), dotGit));
|
setGitDir(getSymRef(getWorkTree(), dotGit, safeFS()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue