summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorHan-Wen Nienhuys <hanwen@google.com>2018-02-14 18:23:03 +0100
committerDavid Pursehouse <david.pursehouse@gmail.com>2018-02-19 20:24:07 +0900
commit446a7096ef01c0e3bb56736403d91b125b2ee6ba (patch)
tree6d1b84f787f3381f277d824bc02947c076750f7b /org.eclipse.jgit
parent35bb7ccc4c9ac39a8dd56dc1c192793cf128b171 (diff)
downloadjgit-446a7096ef01c0e3bb56736403d91b125b2ee6ba.tar.gz
jgit-446a7096ef01c0e3bb56736403d91b125b2ee6ba.zip
RepoCommand: persist unreadable submodules in .gitmodules
In cases where a manifest file mixes different remotes, a Gerrit server process may not have access to all remotes, and won't be able to produce a full submodule tree. Preserving this information in .gitmodules will let downstream clients reconstruct the full tree. Signed-off-by: Han-Wen Nienhuys <hanwen@google.com> Change-Id: I52f5d3f288e771dca0af2b4dd3f3fa0f940dcf15
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java59
1 files changed, 29 insertions, 30 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 10bd6005b5..24651b9b6b 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java
@@ -543,10 +543,7 @@ public class RepoCommand extends GitCommand<RevCommit> {
objectId = ObjectId.fromString(proj.getRevision());
} else {
objectId = callback.sha1(nameUri, proj.getRevision());
- if (objectId == null) {
- if (ignoreRemoteFailures) {
- continue;
- }
+ if (objectId == null && !ignoreRemoteFailures) {
throw new RemoteUnavailableException(nameUri);
}
if (recordRemoteBranch) {
@@ -585,38 +582,40 @@ public class RepoCommand extends GitCommand<RevCommit> {
cfg.setString("submodule", path, "url", submodUrl.toString()); //$NON-NLS-1$ //$NON-NLS-2$
// create gitlink
- DirCacheEntry dcEntry = new DirCacheEntry(path);
- dcEntry.setObjectId(objectId);
- dcEntry.setFileMode(FileMode.GITLINK);
- builder.add(dcEntry);
-
- for (CopyFile copyfile : proj.getCopyFiles()) {
- byte[] src = callback.readFile(
- nameUri, proj.getRevision(), copyfile.src);
- objectId = inserter.insert(Constants.OBJ_BLOB, src);
- dcEntry = new DirCacheEntry(copyfile.dest);
+ if (objectId != null) {
+ DirCacheEntry dcEntry = new DirCacheEntry(path);
dcEntry.setObjectId(objectId);
- dcEntry.setFileMode(FileMode.REGULAR_FILE);
+ dcEntry.setFileMode(FileMode.GITLINK);
builder.add(dcEntry);
- }
- for (LinkFile linkfile : proj.getLinkFiles()) {
- String link;
- if (linkfile.dest.contains("/")) { //$NON-NLS-1$
- link = FileUtils.relativizeGitPath(
+
+ for (CopyFile copyfile : proj.getCopyFiles()) {
+ byte[] src = callback.readFile(
+ nameUri, proj.getRevision(), copyfile.src);
+ objectId = inserter.insert(Constants.OBJ_BLOB, src);
+ dcEntry = new DirCacheEntry(copyfile.dest);
+ dcEntry.setObjectId(objectId);
+ dcEntry.setFileMode(FileMode.REGULAR_FILE);
+ builder.add(dcEntry);
+ }
+ for (LinkFile linkfile : proj.getLinkFiles()) {
+ String link;
+ if (linkfile.dest.contains("/")) { //$NON-NLS-1$
+ link = FileUtils.relativizeGitPath(
linkfile.dest.substring(0,
- linkfile.dest.lastIndexOf('/')),
+ linkfile.dest.lastIndexOf('/')),
proj.getPath() + "/" + linkfile.src); //$NON-NLS-1$
- } else {
- link = proj.getPath() + "/" + linkfile.src; //$NON-NLS-1$
- }
+ } else {
+ link = proj.getPath() + "/" + linkfile.src; //$NON-NLS-1$
+ }
- objectId = inserter.insert(Constants.OBJ_BLOB,
+ objectId = inserter.insert(Constants.OBJ_BLOB,
link.getBytes(
- Constants.CHARACTER_ENCODING));
- dcEntry = new DirCacheEntry(linkfile.dest);
- dcEntry.setObjectId(objectId);
- dcEntry.setFileMode(FileMode.SYMLINK);
- builder.add(dcEntry);
+ Constants.CHARACTER_ENCODING));
+ dcEntry = new DirCacheEntry(linkfile.dest);
+ dcEntry.setObjectId(objectId);
+ dcEntry.setFileMode(FileMode.SYMLINK);
+ builder.add(dcEntry);
+ }
}
}
String content = cfg.toText();