aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@gmail.com>2017-03-24 10:26:44 +0900
committerMatthias Sohn <matthias.sohn@sap.com>2017-06-11 12:24:12 +0200
commitb6f954ad426f91561b4aa09d7ba23652516e7b0a (patch)
tree2e17a47047fc0ef2b48aea04b6b1bbbeaa404569 /org.eclipse.jgit/src/org
parent325b51dbd4ada37ab8890f38f2bbc046ee9bb92e (diff)
downloadjgit-b6f954ad426f91561b4aa09d7ba23652516e7b0a.tar.gz
jgit-b6f954ad426f91561b4aa09d7ba23652516e7b0a.zip
Fetch: Add --recurse-submodules and --no-recurse-submodules options
Add options to control recursion into submodules on fetch. Add a callback interface on FetchCommand, to allow Fetch to display an update "Fetching submodule XYZ" for each submodule. Change-Id: Id805044b57289ee0f384b434aba1dbd2fd317e5b Signed-off-by: David Pursehouse <david.pursehouse@gmail.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit/src/org')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java34
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/SubmoduleConfig.java13
2 files changed, 45 insertions, 2 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java
index cc3302b486..785c20c8af 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java
@@ -99,6 +99,24 @@ public class FetchCommand extends TransportCommand<FetchCommand, FetchResult> {
private FetchRecurseSubmodulesMode submoduleRecurseMode = null;
+ private Callback callback;
+
+ /**
+ * Callback for status of fetch operation.
+ *
+ * @since 4.8
+ *
+ */
+ public interface Callback {
+ /**
+ * Notify fetching a submodule.
+ *
+ * @param name
+ * the submodule name.
+ */
+ void fetchingSubmodule(String name);
+ }
+
/**
* @param repo
*/
@@ -173,6 +191,9 @@ public class FetchCommand extends TransportCommand<FetchCommand, FetchResult> {
.setThin(thin).setRefSpecs(refSpecs)
.setDryRun(dryRun)
.setRecurseSubmodules(recurseMode);
+ if (callback != null) {
+ callback.fetchingSubmodule(walk.getPath());
+ }
results.addSubmodule(walk.getPath(), f.call());
}
}
@@ -434,4 +455,17 @@ public class FetchCommand extends TransportCommand<FetchCommand, FetchResult> {
this.tagOption = tagOpt;
return this;
}
+
+ /**
+ * Register a progress callback.
+ *
+ * @param callback
+ * the callback
+ * @return {@code this}
+ * @since 4.8
+ */
+ public FetchCommand setCallback(Callback callback) {
+ this.callback = callback;
+ return this;
+ }
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/SubmoduleConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/SubmoduleConfig.java
index 3126160c33..12f7b82343 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/SubmoduleConfig.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/SubmoduleConfig.java
@@ -43,6 +43,10 @@
package org.eclipse.jgit.lib;
+import java.util.Locale;
+
+import org.eclipse.jgit.util.StringUtils;
+
/**
* Submodule section of a Git configuration file.
*
@@ -75,12 +79,17 @@ public class SubmoduleConfig {
@Override
public String toConfigValue() {
- return configValue;
+ return name().toLowerCase(Locale.ROOT).replace('_', '-');
}
@Override
public boolean matchConfigValue(String s) {
- return configValue.equals(s);
+ if (StringUtils.isEmptyOrNull(s)) {
+ return false;
+ }
+ s = s.replace('-', '_');
+ return name().equalsIgnoreCase(s)
+ || configValue.equalsIgnoreCase(s);
}
}
}