summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorMichael FIG <michael@fig.org>2017-06-28 15:33:07 -0600
committerMatthias Sohn <matthias.sohn@sap.com>2017-09-20 21:49:46 +0200
commit06835f3e4f0053bb4b39baa02ba4ec32abf3085e (patch)
treef71e2b20117b645a234a918d6f6427d527928c8b /org.eclipse.jgit
parentd946f95c9c06f27de8aac6ecc3f5d49eabe6e030 (diff)
downloadjgit-06835f3e4f0053bb4b39baa02ba4ec32abf3085e.tar.gz
jgit-06835f3e4f0053bb4b39baa02ba4ec32abf3085e.zip
Fetch submodule repo before resolving commits
By default, this is turned off unless cmd.setFetch(true) is given. It will default to true in a future release to mimic c-git behaviour. This is needed to prevent Eclipse from crashing with "Missing unknown [REF]" when cloning a repo with submodules. Bug: 470318 Change-Id: I8ae37c7c5bd2408cead8d57dd13e93e01e0e9dc1 Signed-off-by: Michael FIG <michael@fig.org> Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleUpdateCommand.java29
1 files changed, 28 insertions, 1 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleUpdateCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleUpdateCommand.java
index 4d3dff02cd..c0aeb83d49 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleUpdateCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleUpdateCommand.java
@@ -91,6 +91,8 @@ public class SubmoduleUpdateCommand extends
private CloneCommand.Callback callback;
+ private boolean fetch = false;
+
/**
* @param repo
*/
@@ -114,6 +116,19 @@ public class SubmoduleUpdateCommand extends
}
/**
+ * Whether to fetch the submodules before we update them. By default, this
+ * is set to <code>false</code>
+ *
+ * @param fetch
+ * @return this command
+ * @since 4.9
+ */
+ public SubmoduleUpdateCommand setFetch(final boolean fetch) {
+ this.fetch = fetch;
+ return this;
+ }
+
+ /**
* Add repository-relative submodule path to initialize
*
* @param path
@@ -161,7 +176,7 @@ public class SubmoduleUpdateCommand extends
continue;
Repository submoduleRepo = generator.getRepository();
- // Clone repository is not present
+ // Clone repository if not present
if (submoduleRepo == null) {
if (callback != null) {
callback.cloningSubmodule(generator.getPath());
@@ -175,6 +190,18 @@ public class SubmoduleUpdateCommand extends
if (monitor != null)
clone.setProgressMonitor(monitor);
submoduleRepo = clone.call().getRepository();
+ } else if (this.fetch) {
+ if (callback != null) {
+ // FIXME: Do we need a new callback to tell them we're
+ // fetching?
+ callback.cloningSubmodule(generator.getPath());
+ }
+ FetchCommand fetchCommand = Git.wrap(submoduleRepo).fetch();
+ if (monitor != null) {
+ fetchCommand.setProgressMonitor(monitor);
+ }
+ configure(fetchCommand);
+ fetchCommand.call();
}
try (RevWalk walk = new RevWalk(submoduleRepo)) {