Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/submodule/SubmoduleWalk.java')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/submodule/SubmoduleWalk.java53
1 files changed, 19 insertions, 34 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/submodule/SubmoduleWalk.java b/org.eclipse.jgit/src/org/eclipse/jgit/submodule/SubmoduleWalk.java
index 78896f8a54..f07f4d6c66 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/submodule/SubmoduleWalk.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/submodule/SubmoduleWalk.java
@@ -155,27 +155,32 @@ public class SubmoduleWalk {
*/
public static Repository getSubmoduleRepository(final Repository parent,
final String path) throws IOException {
- File directory = getSubmoduleGitDirectory(parent, path);
- if (!directory.isDirectory())
- return null;
- try {
- return new RepositoryBuilder().setMustExist(true)
- .setFS(FS.DETECTED).setGitDir(directory).build();
- } catch (RepositoryNotFoundException e) {
- return null;
- }
+ return getSubmoduleRepository(parent.getWorkTree(), path);
}
/**
- * Get the .git directory for a repository submodule path
+ * Get submodule repository at path
*
* @param parent
* @param path
- * @return .git for submodule repository
+ * @return repository or null if repository doesn't exist
+ * @throws IOException
*/
- public static File getSubmoduleGitDirectory(final Repository parent,
- final String path) {
- return new File(getSubmoduleDirectory(parent, path), Constants.DOT_GIT);
+ public static Repository getSubmoduleRepository(final File parent,
+ final String path) throws IOException {
+ File subWorkTree = new File(parent, path);
+ if (!subWorkTree.isDirectory())
+ return null;
+ File workTree = new File(parent, path);
+ try {
+ return new RepositoryBuilder() //
+ .setMustExist(true) //
+ .setFS(FS.DETECTED) //
+ .setWorkTree(workTree) //
+ .build();
+ } catch (RepositoryNotFoundException e) {
+ return null;
+ }
}
/**
@@ -349,15 +354,6 @@ public class SubmoduleWalk {
}
/**
- * Get the .git directory for the current submodule entry
- *
- * @return .git for submodule repository
- */
- public File getGitDirectory() {
- return getSubmoduleGitDirectory(repository, path);
- }
-
- /**
* Advance to next submodule in the index tree.
*
* The object id and path of the next entry can be obtained by calling
@@ -467,19 +463,8 @@ public class SubmoduleWalk {
}
/**
- * Does the current submodule entry have a .git directory in the parent
- * repository's working tree?
- *
- * @return true if .git directory exists, false otherwise
- */
- public boolean hasGitDirectory() {
- return getGitDirectory().isDirectory();
- }
-
- /**
* Get repository for current submodule entry
*
- * @see #hasGitDirectory()
* @return repository or null if non-existent
* @throws IOException
*/

Back to the top