aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorKevin Sawicki <kevin@github.com>2012-04-01 18:36:42 -0700
committerKevin Sawicki <kevin@github.com>2012-04-01 18:36:42 -0700
commit543c5238ae3578f37cb9ada36b95775fa564e41d (patch)
tree1bdce0af4ace2915f39e9651ae5f8de40c4f2c4e /org.eclipse.jgit
parent6189a68d1d48e38779380cea81efa530405ff762 (diff)
downloadjgit-543c5238ae3578f37cb9ada36b95775fa564e41d.tar.gz
jgit-543c5238ae3578f37cb9ada36b95775fa564e41d.zip
Recurse into cloned submodules
Iterate over all successfully cloned submodules recursively and continue initializing and updating until no more are found. Bug: 375426 Change-Id: Ifb99e41e2deb0c369442bca3c0f5f072dd006816
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java12
1 files changed, 10 insertions, 2 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java
index ef5b7291b7..f354de1657 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java
@@ -66,6 +66,7 @@ import org.eclipse.jgit.lib.RefUpdate;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
+import org.eclipse.jgit.submodule.SubmoduleWalk;
import org.eclipse.jgit.transport.FetchResult;
import org.eclipse.jgit.transport.RefSpec;
import org.eclipse.jgit.transport.RemoteConfig;
@@ -229,7 +230,7 @@ public class CloneCommand extends TransportCommand<CloneCommand, Git> {
}
}
- private void cloneSubmodules(Repository clonedRepo) {
+ private void cloneSubmodules(Repository clonedRepo) throws IOException {
SubmoduleInitCommand init = new SubmoduleInitCommand(clonedRepo);
if (init.call().isEmpty())
return;
@@ -237,7 +238,14 @@ public class CloneCommand extends TransportCommand<CloneCommand, Git> {
SubmoduleUpdateCommand update = new SubmoduleUpdateCommand(clonedRepo);
configure(update);
update.setProgressMonitor(monitor);
- update.call();
+ if (!update.call().isEmpty()) {
+ SubmoduleWalk walk = SubmoduleWalk.forIndex(clonedRepo);
+ while (walk.next()) {
+ Repository subRepo = walk.getRepository();
+ if (subRepo != null)
+ cloneSubmodules(subRepo);
+ }
+ }
}
private Ref findBranchToCheckout(FetchResult result) {