summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm/src
diff options
context:
space:
mode:
authorChristian Halstrick <christian.halstrick@sap.com>2016-10-17 02:41:17 -0400
committerGerrit Code Review @ Eclipse.org <gerrit@eclipse.org>2016-10-17 02:41:19 -0400
commitfb4abc7f86938b9e20812cd7a93cf0b3fcf7c6ea (patch)
tree8ba1f4a4497dd013d0761bd151dce2a8cd35bb4e /org.eclipse.jgit.pgm/src
parentba7ba7a816ad7e936f413a3c7686deb790cce525 (diff)
parent293e8beaccafced255ccd354adab36de0257352f (diff)
downloadjgit-fb4abc7f86938b9e20812cd7a93cf0b3fcf7c6ea.tar.gz
jgit-fb4abc7f86938b9e20812cd7a93cf0b3fcf7c6ea.zip
Merge "Fix JGit CLI to follow native git's interpretation of http_proxy..."
Diffstat (limited to 'org.eclipse.jgit.pgm/src')
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java21
1 files changed, 16 insertions, 5 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java
index 3ddee36e3b..67a641db86 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java
@@ -343,17 +343,28 @@ public class Main {
* <code>https_proxy</code> environment variables as a means of specifying
* an HTTP/S proxy for requests made behind a firewall. This is not natively
* recognized by the JRE, so this method can be used by command line
- * utilities to configure the JRE before the first request is sent.
+ * utilities to configure the JRE before the first request is sent. The
+ * information found in the environment variables is copied to the
+ * associated system properties. This is not done when the system properties
+ * are already set. The default way of telling java programs about proxies
+ * (the system properties) takes precedence over environment variables.
*
* @throws MalformedURLException
* the value in <code>http_proxy</code> or
* <code>https_proxy</code> is unsupportable.
*/
- private static void configureHttpProxy() throws MalformedURLException {
+ static void configureHttpProxy() throws MalformedURLException {
for (String protocol : new String[] { "http", "https" }) { //$NON-NLS-1$ //$NON-NLS-2$
- final String s = System.getenv(protocol + "_proxy"); //$NON-NLS-1$
- if (s == null || s.equals("")) //$NON-NLS-1$
- return;
+ if (System.getProperty(protocol + ".proxyHost") != null) { //$NON-NLS-1$
+ continue;
+ }
+ String s = System.getenv(protocol + "_proxy"); //$NON-NLS-1$
+ if (s == null && protocol.equals("https")) {
+ s = System.getenv("HTTPS_PROXY"); //$NON-NLS-1$
+ }
+ if (s == null || s.equals("")) { //$NON-NLS-1$
+ continue;
+ }
final URL u = new URL(
(s.indexOf("://") == -1) ? protocol + "://" + s : s); //$NON-NLS-1$ //$NON-NLS-2$