summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorJonathan Nieder <jrn@google.com>2015-10-05 19:24:46 -0400
committerGerrit Code Review @ Eclipse.org <gerrit@eclipse.org>2015-10-05 19:24:48 -0400
commitc2efb5c96468d718f3037134257ce99e00f9c60e (patch)
treecc66130483fb9bea2fbb9f409a629aeadd64d50e /org.eclipse.jgit
parentccad3c7df666ce83043a1e414cda613e6bfc5929 (diff)
parentcdd7c23446a0030e5b521d91cbb2d3a9c522ccc2 (diff)
downloadjgit-c2efb5c96468d718f3037134257ce99e00f9c60e.tar.gz
jgit-c2efb5c96468d718f3037134257ce99e00f9c60e.zip
Merge "RepoCommand: Add setRecordRemoteBranch option to record upstream branch"
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java33
1 files changed, 31 insertions, 2 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 790f4db672..d298331f54 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java
@@ -106,6 +106,7 @@ public class RepoCommand extends GitCommand<RevCommit> {
private String groups;
private String branch;
private String targetBranch = Constants.HEAD;
+ private boolean recordRemoteBranch = false;
private PersonIdent author;
private RemoteReader callback;
private InputStream inputStream;
@@ -314,6 +315,30 @@ public class RepoCommand extends GitCommand<RevCommit> {
}
/**
+ * 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.
+ * <p>
+ * That field is used by "git submodule update --remote" to update
+ * to the tip of the tracked branch when asked and by Gerrit to
+ * update the superproject when a change on that branch is merged.
+ * <p>
+ * Subprojects that request a specific commit or tag will not have
+ * a branch name recorded.
+ * <p>
+ * Not implemented for non-bare repositories.
+ *
+ * @param record Whether to record the branch name
+ * @return this command
+ * @since 4.2
+ */
+ public RepoCommand setRecordRemoteBranch(boolean update) {
+ this.recordRemoteBranch = update;
+ return this;
+ }
+
+ /**
* The progress monitor associated with the clone operation. By default,
* this is set to <code>NullProgressMonitor</code>
*
@@ -429,10 +454,14 @@ public class RepoCommand extends GitCommand<RevCommit> {
// create gitlink
DirCacheEntry dcEntry = new DirCacheEntry(name);
ObjectId objectId;
- if (ObjectId.isId(proj.getRevision()))
+ if (ObjectId.isId(proj.getRevision())) {
objectId = ObjectId.fromString(proj.getRevision());
- else {
+ } else {
objectId = callback.sha1(nameUri, proj.getRevision());
+ 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);