aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/lib
diff options
context:
space:
mode:
authorThomas Wolf <thomas.wolf@paranor.ch>2022-02-10 19:04:21 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2022-02-14 10:45:15 +0100
commit855a734875c2f178a8adfd0789527afc8754117f (patch)
treeb488222bb7573e9c06862b7bf1b2832ae92c8eeb /org.eclipse.jgit/src/org/eclipse/jgit/lib
parent504001228ba6a43179a72e56ce03aa217c2bdea4 (diff)
downloadjgit-855a734875c2f178a8adfd0789527afc8754117f.tar.gz
jgit-855a734875c2f178a8adfd0789527afc8754117f.zip
PushCommand: determine remote from git config if not given
Add ConfigConstants and expose branch.<name>.pushRemote in the BranchConfig. Use the branch configuration and remote.pushDefault if no remote is given explicitly. If nothing is configured, fall back to "origin". Bug: 578676 Change-Id: I6bb141ff02c8b04980ec34b26ef248b72614c3c9 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/lib')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/BranchConfig.java12
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java14
2 files changed, 26 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BranchConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BranchConfig.java
index 6da6f1204a..aa613d07eb 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BranchConfig.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BranchConfig.java
@@ -138,6 +138,18 @@ public class BranchConfig {
}
/**
+ * Get the remote this branch is configured to push to.
+ *
+ * @return the remote this branch is configured to push to, or {@code null}
+ * if not defined
+ * @since 6.1
+ */
+ public String getPushRemote() {
+ return config.getString(ConfigConstants.CONFIG_BRANCH_SECTION,
+ branchName, ConfigConstants.CONFIG_KEY_PUSH_REMOTE);
+ }
+
+ /**
* Get the name of the upstream branch as it is called on the remote
*
* @return the name of the upstream branch as it is called on the remote, or
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java
index 205999f8c9..42d8aa5447 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java
@@ -329,6 +329,20 @@ public final class ConfigConstants {
/** The "remote" key */
public static final String CONFIG_KEY_REMOTE = "remote";
+ /**
+ * The "pushRemote" key.
+ *
+ * @since 6.1
+ */
+ public static final String CONFIG_KEY_PUSH_REMOTE = "pushRemote";
+
+ /**
+ * The "pushDefault" key.
+ *
+ * @since 6.1
+ */
+ public static final String CONFIG_KEY_PUSH_DEFAULT = "pushDefault";
+
/** The "merge" key */
public static final String CONFIG_KEY_MERGE = "merge";