diff options
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java | 26 |
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. |