summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@gmail.com>2018-02-22 00:37:48 -0500
committerGerrit Code Review @ Eclipse.org <gerrit@eclipse.org>2018-02-22 00:37:48 -0500
commit0e20df710a738d231252b53b41f77459718087ac (patch)
treec888783dfe90384de8b5fe89cbaac2a5f6e1de4d /org.eclipse.jgit
parent372e04dcf3679a72ec9519ae848f672779a0d8be (diff)
parent6a420613f7dae0f58496e259859d1a6cf1965f5b (diff)
downloadjgit-0e20df710a738d231252b53b41f77459718087ac.tar.gz
jgit-0e20df710a738d231252b53b41f77459718087ac.zip
Merge changes Id616611e,Ib6509e81,I52f5d3f2
* changes: RepoCommand: generate relative submodule URLs from absolute URLs. RepoCommand: don't record new commit if tree did not change RepoCommand: persist unreadable submodules in .gitmodules
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java72
1 files changed, 36 insertions, 36 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..8b8df87978 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.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
import java.util.StringJoiner;
@@ -543,10 +544,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 +583,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();
@@ -644,6 +644,11 @@ public class RepoCommand extends GitCommand<RevCommit> {
// Create a Commit object, populate it and write it
ObjectId headId = repo.resolve(targetBranch + "^{commit}"); //$NON-NLS-1$
+ if (headId != null && rw.parseCommit(headId).getTree().getId().equals(treeId)) {
+ // No change. Do nothing.
+ return rw.parseCommit(headId);
+ }
+
CommitBuilder commit = new CommitBuilder();
commit.setTreeId(treeId);
if (headId != null)
@@ -745,12 +750,7 @@ public class RepoCommand extends GitCommand<RevCommit> {
*/
private static final String SLASH = "/"; //$NON-NLS-1$
static URI relativize(URI current, URI target) {
-
- // We only handle bare paths for now.
- if (!target.toString().equals(target.getPath())) {
- return target;
- }
- if (!current.toString().equals(current.getPath())) {
+ if (!Objects.equals(current.getHost(), target.getHost())) {
return target;
}