Skip to content

Commit 876490b

Browse files
committed
Support absoulte path in git submodule gitdirs
When using git submodules, some versions of git (e.g., 1.7.9) use abosulate path in the gitdir reference of the submodules. This patch adds support to handle absoluate path correctly.
1 parent 33ce1f2 commit 876490b

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/main/java/pl/project13/maven/git/GitDirLocator.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public File lookupGitDirectory(@NotNull File manuallyConfiguredDir) {
4646

4747
if (manuallyConfiguredDir.exists()) {
4848

49-
// If manuallyConfiguredDir is a directory then we can use it as the git path.
49+
// If manuallyConfiguredDir is a directory then we can use it as the git path.
5050
if (manuallyConfiguredDir.isDirectory()) {
5151
return manuallyConfiguredDir;
5252
}
@@ -158,7 +158,14 @@ private File processGitDirFile(@NotNull File file) {
158158
}
159159

160160
// All seems ok so return the "gitdir" value read from the file.
161-
return new File(file.getParentFile(), parts[1]);
161+
File gitDir = new File(parts[1]);
162+
if (gitDir.isAbsolute()) {
163+
// gitdir value is an absolute path. Return as-is
164+
return gitDir;
165+
} else {
166+
// gitdir value is relative.
167+
return new File(file.getParentFile(), parts[1]);
168+
}
162169
} catch (FileNotFoundException e) {
163170
return null;
164171
} finally {

0 commit comments

Comments
 (0)