Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki2012-01-02 17:38:21 +0000
committerKevin Sawicki2012-01-03 01:32:41 +0000
commitd57c00e03696571afd92baf76cce03275b158bef (patch)
tree4f529c8439b7e35a6f930c3d7b6a47312f04dd78 /org.eclipse.jgit
parentdea451157200a216b135551e203242f229aac082 (diff)
downloadjgit-d57c00e03696571afd92baf76cce03275b158bef.tar.gz
jgit-d57c00e03696571afd92baf76cce03275b158bef.tar.xz
jgit-d57c00e03696571afd92baf76cce03275b158bef.zip
Add support for cloning submodules to CloneCommand
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java26
1 files changed, 26 insertions, 0 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 b779c488aa..ae72b770fe 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java
@@ -94,6 +94,8 @@ public class CloneCommand extends TransportCommand<CloneCommand, Git> {
private boolean cloneAllBranches;
+ private boolean cloneSubmodules;
+
private boolean noCheckout;
private Collection<String> branchesToClone;
@@ -222,9 +224,22 @@ public class CloneCommand extends TransportCommand<CloneCommand, Git> {
DirCacheCheckout co = new DirCacheCheckout(clonedRepo, dc,
commit.getTree());
co.checkout();
+ if (cloneSubmodules)
+ cloneSubmodules(clonedRepo);
}
}
+ private void cloneSubmodules(Repository clonedRepo) {
+ SubmoduleInitCommand init = new SubmoduleInitCommand(clonedRepo);
+ if (init.call().isEmpty())
+ return;
+
+ SubmoduleUpdateCommand update = new SubmoduleUpdateCommand(clonedRepo);
+ configure(update);
+ update.setProgressMonitor(monitor);
+ update.call();
+ }
+
private Ref findBranchToCheckout(FetchResult result) {
final Ref idHEAD = result.getAdvertisedRef(Constants.HEAD);
if (idHEAD == null)
@@ -357,6 +372,17 @@ public class CloneCommand extends TransportCommand<CloneCommand, Git> {
}
/**
+ * @param cloneSubmodules
+ * true to initialize and update submodules. Ignored when
+ * {@link #setBare(boolean)} is set to true.
+ * @return {@code this}
+ */
+ public CloneCommand setCloneSubmodules(boolean cloneSubmodules) {
+ this.cloneSubmodules = cloneSubmodules;
+ return this;
+ }
+
+ /**
* @param branchesToClone
* collection of branches to clone. Ignored when allSelected is
* true.

Back to the top