aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties3
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AbstractFetchCommand.java3
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Fetch.java46
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java2
-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
6 files changed, 97 insertions, 4 deletions
diff --git a/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties b/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties
index d8c3329695..c3d7c685ff 100644
--- a/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties
+++ b/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties
@@ -67,12 +67,14 @@ failedToLockIndex=failed to lock index
failedToLockTag=Failed to lock tag {0}: {1}
fatalError=fatal: {0}
fatalThisProgramWillDestroyTheRepository=fatal: This program will destroy the repository\nfatal:\nfatal:\nfatal: {0}\nfatal:\nfatal: To continue, add {1} to the command line\nfatal:
+fetchingSubmodule=Fetching submodule {0}
fileIsRequired=argument file is required
ffNotPossibleAborting=Not possible to fast-forward, aborting.
forcedUpdate=forced update
fromURI=From {0}
initializedEmptyGitRepositoryIn=Initialized empty Git repository in {0}
invalidHttpProxyOnlyHttpSupported=Invalid http_proxy: {0}: Only http supported.
+invalidRecurseSubmodulesMode=Invalid recurse submodules mode: {0}
jgitVersion=jgit version {0}
lineFormat={0}
listeningOn=Listening on {0}
@@ -359,6 +361,7 @@ usage_noCheckoutAfterClone=no checkout of HEAD is performed after the clone is c
usage_noCommit=Don't commit after a successful merge
usage_noPrefix=do not show any source or destination prefix
usage_noRenames=disable rename detection
+usage_noRecurseSubmodules=Disable recursive fetching of submodules (this has the same effect as using the --recurse-submodules=no option)
usage_noShowStandardNotes=Disable showing notes from the standard /refs/notes/commits branch
usage_onlyMatchAgainstAlreadyTrackedFiles=Only match <filepattern> against already tracked files in the index rather than the working tree
usage_outputFile=Output file
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AbstractFetchCommand.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AbstractFetchCommand.java
index 2cee2cb007..08ec0964fc 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AbstractFetchCommand.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AbstractFetchCommand.java
@@ -90,6 +90,9 @@ abstract class AbstractFetchCommand extends TextBuiltin {
}
}
showRemoteMessages(errw, r.getMessages());
+ for (FetchResult submoduleResult : r.submoduleResults().values()) {
+ showFetchResult(submoduleResult);
+ }
}
static void showRemoteMessages(ThrowingPrintWriter writer, String pkt) throws IOException {
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Fetch.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Fetch.java
index ed06733a44..5ed23b9ffa 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Fetch.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Fetch.java
@@ -45,11 +45,15 @@
package org.eclipse.jgit.pgm;
+import java.io.IOException;
+import java.text.MessageFormat;
import java.util.List;
import org.eclipse.jgit.api.FetchCommand;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.lib.SubmoduleConfig.FetchRecurseSubmodulesMode;
+import org.eclipse.jgit.pgm.internal.CLIText;
import org.eclipse.jgit.lib.TextProgressMonitor;
import org.eclipse.jgit.transport.FetchResult;
import org.eclipse.jgit.transport.RefSpec;
@@ -58,7 +62,7 @@ import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.Option;
@Command(common = true, usage = "usage_updateRemoteRefsFromAnotherRepository")
-class Fetch extends AbstractFetchCommand {
+class Fetch extends AbstractFetchCommand implements FetchCommand.Callback {
@Option(name = "--timeout", metaVar = "metaVar_seconds", usage = "usage_abortConnectionIfNoActivity")
int timeout = -1;
@@ -96,6 +100,31 @@ class Fetch extends AbstractFetchCommand {
tags = Boolean.FALSE;
}
+ private FetchRecurseSubmodulesMode recurseSubmodules;
+
+ @Option(name = "--recurse-submodules", usage = "usage_recurseSubmodules")
+ void recurseSubmodules(String mode) {
+ if (mode == null || mode.isEmpty()) {
+ recurseSubmodules = FetchRecurseSubmodulesMode.YES;
+ } else {
+ for (FetchRecurseSubmodulesMode m : FetchRecurseSubmodulesMode
+ .values()) {
+ if (m.matchConfigValue(mode)) {
+ recurseSubmodules = m;
+ return;
+ }
+ }
+ throw die(MessageFormat
+ .format(CLIText.get().invalidRecurseSubmodulesMode, mode));
+ }
+ }
+
+ @Option(name = "--no-recurse-submodules", usage = "usage_noRecurseSubmodules")
+ void noRecurseSubmodules(@SuppressWarnings("unused")
+ final boolean ignored) {
+ recurseSubmodules = FetchRecurseSubmodulesMode.NO;
+ }
+
@Argument(index = 0, metaVar = "metaVar_uriish")
private String remote = Constants.DEFAULT_REMOTE_NAME;
@@ -124,12 +153,25 @@ class Fetch extends AbstractFetchCommand {
fetch.setThin(thin.booleanValue());
if (quiet == null || !quiet.booleanValue())
fetch.setProgressMonitor(new TextProgressMonitor(errw));
+ fetch.setRecurseSubmodules(recurseSubmodules).setCallback(this);
FetchResult result = fetch.call();
- if (result.getTrackingRefUpdates().isEmpty())
+ if (result.getTrackingRefUpdates().isEmpty()
+ && result.submoduleResults().isEmpty())
return;
showFetchResult(result);
}
}
+
+ @Override
+ public void fetchingSubmodule(String name) {
+ try {
+ outw.println(MessageFormat.format(CLIText.get().fetchingSubmodule,
+ name));
+ outw.flush();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java
index e10ecbeebc..e012372b92 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java
@@ -143,12 +143,14 @@ public class CLIText extends TranslationBundle {
/***/ public String failedToLockTag;
/***/ public String fatalError;
/***/ public String fatalThisProgramWillDestroyTheRepository;
+ /***/ public String fetchingSubmodule;
/***/ public String fileIsRequired;
/***/ public String ffNotPossibleAborting;
/***/ public String forcedUpdate;
/***/ public String fromURI;
/***/ public String initializedEmptyGitRepositoryIn;
/***/ public String invalidHttpProxyOnlyHttpSupported;
+ /***/ public String invalidRecurseSubmodulesMode;
/***/ public String jgitVersion;
/***/ public String lfsNoAccessKey;
/***/ public String lfsNoSecretKey;
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);
}
}
}