Merge branch 'kf/http-proxy-auth-methods'
authorJunio C Hamano <gitster@pobox.com>
Wed, 3 Feb 2016 22:16:08 +0000 (14:16 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 3 Feb 2016 22:16:08 +0000 (14:16 -0800)
New http.proxyAuthMethod configuration variable can be used to
specify what authentication method to use, as a way to work around
proxies that do not give error response expected by libcurl when
CURLAUTH_ANY is used. Also, the codepath for proxy authentication
has been taught to use credential API to store the authentication
material in user's keyrings.

* kf/http-proxy-auth-methods:
http: use credential API to handle proxy authentication
http: allow selection of proxy authentication method

1  2 
Documentation/config.txt
remote.c
diff --combined Documentation/config.txt
index 877cbc875ec38ef7dca9f3e2a2c860ea9a2f1790,8b969497ba3f92385211d2aa599947578fdd3c72..02bcde6bb596ee5a82fa5630396fa78925abc2b0
@@@ -870,8 -870,6 +870,8 @@@ When preserve, also pass `--preserve-me
  so that locally committed merge commits will not be flattened
  by running 'git pull'.
  +
 +When the value is `interactive`, the rebase is run in interactive mode.
 ++
  *NOTE*: this is a possibly dangerous operation; do *not* use
  it unless you understand the implications (see linkgit:git-rebase[1]
  for details).
@@@ -1245,10 -1243,6 +1245,10 @@@ format.coverLetter:
        format-patch is invoked, but in addition can be set to "auto", to
        generate a cover-letter only when there's more than one patch.
  
 +format.outputDirectory::
 +      Set a custom directory to store the resulting files instead of the
 +      current working directory.
 +
  filter.<driver>.clean::
        The command which is used to convert the content of a worktree
        file to a blob upon checkin.  See linkgit:gitattributes[5] for
@@@ -1456,14 -1450,6 +1456,14 @@@ grep.extendedRegexp:
        option is ignored when the 'grep.patternType' option is set to a value
        other than 'default'.
  
 +grep.threads::
 +      Number of grep worker threads to use.
 +      See `grep.threads` in linkgit:git-grep[1] for more information.
 +
 +grep.fallbackToNoIndex::
 +      If set to true, fall back to git grep --no-index if git grep
 +      is executed outside of a git repository.  Defaults to false.
 +
  gpg.program::
        Use this custom program instead of "gpg" found on $PATH when
        making or verifying a PGP signature. The program must support the
@@@ -1610,9 -1596,34 +1610,34 @@@ help.htmlPath:
  
  http.proxy::
        Override the HTTP proxy, normally configured using the 'http_proxy',
-       'https_proxy', and 'all_proxy' environment variables (see
-       `curl(1)`).  This can be overridden on a per-remote basis; see
-       remote.<name>.proxy
+       'https_proxy', and 'all_proxy' environment variables (see `curl(1)`). In
+       addition to the syntax understood by curl, it is possible to specify a
+       proxy string with a user name but no password, in which case git will
+       attempt to acquire one in the same way it does for other credentials. See
+       linkgit:gitcredentials[7] for more information. The syntax thus is
+       '[protocol://][user[:password]@]proxyhost[:port]'. This can be overridden
+       on a per-remote basis; see remote.<name>.proxy
+ http.proxyAuthMethod::
+       Set the method with which to authenticate against the HTTP proxy. This
+       only takes effect if the configured proxy string contains a user name part
+       (i.e. is of the form 'user@host' or 'user@host:port'). This can be
+       overridden on a per-remote basis; see `remote.<name>.proxyAuthMethod`.
+       Both can be overridden by the 'GIT_HTTP_PROXY_AUTHMETHOD' environment
+       variable.  Possible values are:
+ +
+ --
+ * `anyauth` - Automatically pick a suitable authentication method. It is
+   assumed that the proxy answers an unauthenticated request with a 407
+   status code and one or more Proxy-authenticate headers with supported
+   authentication methods. This is the default.
+ * `basic` - HTTP Basic authentication
+ * `digest` - HTTP Digest authentication; this prevents the password from being
+   transmitted to the proxy in clear text
+ * `negotiate` - GSS-Negotiate authentication (compare the --negotiate option
+   of `curl(1)`)
+ * `ntlm` - NTLM authentication (compare the --ntlm option of `curl(1)`)
+ --
  
  http.cookieFile::
        File containing previously stored cookie lines which should be used
@@@ -2163,8 -2174,6 +2188,8 @@@ When preserve, also pass `--preserve-me
  so that locally committed merge commits will not be flattened
  by running 'git pull'.
  +
 +When the value is `interactive`, the rebase is run in interactive mode.
 ++
  *NOTE*: this is a possibly dangerous operation; do *not* use
  it unless you understand the implications (see linkgit:git-rebase[1]
  for details).
@@@ -2423,6 -2432,11 +2448,11 @@@ remote.<name>.proxy:
        the proxy to use for that remote.  Set to the empty string to
        disable proxying for that remote.
  
+ remote.<name>.proxyAuthMethod::
+       For remotes that require curl (http, https and ftp), the method to use for
+       authenticating against the proxy in use (probably set in
+       `remote.<name>.proxy`). See `http.proxyAuthMethod`.
  remote.<name>.fetch::
        The default set of "refspec" for linkgit:git-fetch[1]. See
        linkgit:git-fetch[1].
diff --combined remote.c
index 7d61dabebb3727e2e70cc282053d3138be5ead9d,0bb5a698324cf0e77589fe8fc4f3e9cbe7d215bf..35940a5602807542eeae12a45bb845e73a99339c
+++ b/remote.c
@@@ -256,7 -256,7 +256,7 @@@ static void read_remotes_file(struct re
        if (!f)
                return;
        remote->origin = REMOTE_REMOTES;
 -      while (strbuf_getline(&buf, f, '\n') != EOF) {
 +      while (strbuf_getline(&buf, f) != EOF) {
                const char *v;
  
                strbuf_rtrim(&buf);
@@@ -281,7 -281,7 +281,7 @@@ static void read_branches_file(struct r
        if (!f)
                return;
  
 -      strbuf_getline(&buf, f, '\n');
 +      strbuf_getline_lf(&buf, f);
        fclose(f);
        strbuf_trim(&buf);
        if (!buf.len) {
@@@ -428,6 -428,9 +428,9 @@@ static int handle_config(const char *ke
        } else if (!strcmp(subkey, ".proxy")) {
                return git_config_string((const char **)&remote->http_proxy,
                                         key, value);
+       } else if (!strcmp(subkey, ".proxyauthmethod")) {
+               return git_config_string((const char **)&remote->http_proxy_authmethod,
+                                        key, value);
        } else if (!strcmp(subkey, ".vcs")) {
                return git_config_string(&remote->foreign_vcs, key, value);
        }