summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java52
1 files changed, 41 insertions, 11 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java
index ff9f233aa5..ee937f585b 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java
@@ -54,6 +54,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import org.eclipse.jgit.annotations.Nullable;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.GitCommand;
import org.eclipse.jgit.api.SubmoduleAddCommand;
@@ -103,7 +104,6 @@ import org.eclipse.jgit.util.FileUtils;
* @since 3.4
*/
public class RepoCommand extends GitCommand<RevCommit> {
-
private String path;
private String uri;
private String groups;
@@ -114,6 +114,7 @@ public class RepoCommand extends GitCommand<RevCommit> {
private RemoteReader callback;
private InputStream inputStream;
private IncludedFileReader includedReader;
+ private boolean ignoreRemoteFailures = false;
private List<RepoProject> bareProjects;
private Git git;
@@ -137,9 +138,11 @@ public class RepoCommand extends GitCommand<RevCommit> {
* The URI of the remote repository
* @param ref
* The ref (branch/tag/etc.) to read
- * @return the sha1 of the remote repository
+ * @return the sha1 of the remote repository, or null if the ref does
+ * not exist.
* @throws GitAPIException
*/
+ @Nullable
public ObjectId sha1(String uri, String ref) throws GitAPIException;
/**
@@ -318,7 +321,7 @@ public class RepoCommand extends GitCommand<RevCommit> {
}
/**
- * Set whether the branch name should be recorded in .gitmodules
+ * Set whether the branch name should be recorded in .gitmodules.
* <p>
* Submodule entries in .gitmodules can include a "branch" field
* to indicate what remote branch each submodule tracks.
@@ -355,6 +358,26 @@ public class RepoCommand extends GitCommand<RevCommit> {
}
/**
+ * Set whether to skip projects whose commits don't exist remotely.
+ * <p>
+ * When set to true, we'll just skip the manifest entry and continue
+ * on to the next one.
+ * <p>
+ * When set to false (default), we'll throw an error when remote
+ * failures occur.
+ * <p>
+ * Not implemented for non-bare repositories.
+ *
+ * @param ignore Whether to ignore the remote failures.
+ * @return this command
+ * @since 4.3
+ */
+ public RepoCommand setIgnoreRemoteFailures(boolean ignore) {
+ this.ignoreRemoteFailures = ignore;
+ return this;
+ }
+
+ /**
* Set the author/committer for the bare repository commit.
* <p>
* For non-bare repositories, the current user will be used and this will be
@@ -452,22 +475,29 @@ public class RepoCommand extends GitCommand<RevCommit> {
for (RepoProject proj : bareProjects) {
String name = proj.getPath();
String nameUri = proj.getName();
- cfg.setString("submodule", name, "path", name); //$NON-NLS-1$ //$NON-NLS-2$
- cfg.setString("submodule", name, "url", nameUri); //$NON-NLS-1$ //$NON-NLS-2$
- // create gitlink
- DirCacheEntry dcEntry = new DirCacheEntry(name);
ObjectId objectId;
- if (ObjectId.isId(proj.getRevision())) {
+ if (ObjectId.isId(proj.getRevision())
+ && !ignoreRemoteFailures) {
objectId = ObjectId.fromString(proj.getRevision());
} else {
objectId = callback.sha1(nameUri, proj.getRevision());
- if (recordRemoteBranch)
+ if (objectId == null) {
+ if (ignoreRemoteFailures) {
+ continue;
+ }
+ throw new RemoteUnavailableException(nameUri);
+ }
+ if (recordRemoteBranch) {
// can be branch or tag
cfg.setString("submodule", name, "branch", //$NON-NLS-1$ //$NON-NLS-2$
proj.getRevision());
+ }
}
- if (objectId == null)
- throw new RemoteUnavailableException(nameUri);
+ cfg.setString("submodule", name, "path", name); //$NON-NLS-1$ //$NON-NLS-2$
+ cfg.setString("submodule", name, "url", nameUri); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // create gitlink
+ DirCacheEntry dcEntry = new DirCacheEntry(name);
dcEntry.setObjectId(objectId);
dcEntry.setFileMode(FileMode.GITLINK);
builder.add(dcEntry);