diff options
Diffstat (limited to 'org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Fetch.java')
-rw-r--r-- | org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Fetch.java | 46 |
1 files changed, 44 insertions, 2 deletions
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 + } + } } |