git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: Brandon Williams <bmwill@google.com>
Cc: git@vger.kernel.org, Jeff King <peff@peff.net>,
	Junio C Hamano <gitster@pobox.com>,
	Jonathan Tan <jonathantanmy@google.com>
Subject: [PATCH] credential doc: make multiple-helper behavior more prominent (Re: [PATCH] clone: handle empty config values in -c)
Date: Mon, 1 May 2017 17:21:14 -0700	[thread overview]
Message-ID: <20170502002114.GV28740@aiede.svl.corp.google.com> (raw)
In-Reply-To: <20170502000856.GI39135@google.com>

Subject: credential doc: make multiple-helper behavior more prominent

Git's configuration system works by reading multiple configuration
files in order, from general to specific:

 - first, the system configuration /etc/gitconfig
 - then the user's configuration (~/.gitconfig or ~/.config/git/config)
 - then the repository configuration (.git/config)

For single-valued configuration items, the latest value wins.  For
multi-valued configuration items, values accumulate in that order.

For example, this allows setting a credential helper globally in
~/.gitconfig that git will try to use in all repositories, regardless
of whether they additionally provide another helper.  This is usually
a nice thing --- e.g. I can install helpers to use my OS keychain and
to cache credentials for a short period of time globally.

Sometimes people want to be able to override an inherited setting.
For the credential.helper setting, this is done by setting the
configuration item to empty before giving it a new value.  This is
already documented by the documentation is hard to find ---
git-config(1) says to look at gitcredentials(7) and the config
reference in gitcredentials(7) doesn't mention this issue.

Move the documentation to the config reference to make it easier to
find.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Brandon Williams wrote:

>> Noticed while trying to set credential.helper during a clone to use a
>> specific helper without inheriting from ~/.gitconfig and
>> /etc/gitconfig.  That is, I ran
>>
>> 	git clone -c credential.helper= \
>> 		-c credential.helper=myhelper \
>> 		https://example.com/repo
>>
>> intending to produce the configuration
>>
>> 	[credential]
>> 		helper =
>> 		helper = myhelper
>>
>> Without this patch, the 'helper =' line is not included and the
>> credential helper from /etc/gitconfig gets used.
>>
>> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
>> ---
>> Thoughts?
>
> After reading this I'm still a little fuzzy on why the empty helper line
> is needed to avoid using the credential helper from /etc/gitconfig.

See "git help credentials":

       If there are multiple instances of the credential.helper configuration
       variable, each helper will be tried in turn, and may provide a
       username, password, or nothing. Once Git has acquired both a username
       and a password, no more helpers will be tried.

       If credential.helper is configured to the empty string, this resets the
       helper list to empty (so you may override a helper set by a
       lower-priority config file by configuring the empty-string helper,
       followed by whatever set of helpers you would like).

That's a bit obscure, though --- I didn't find it when I looked in "git
help config".  How about this patch?

Tested using 'make -C Documentation gitcredentials.7'.

 Documentation/gitcredentials.txt | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/Documentation/gitcredentials.txt b/Documentation/gitcredentials.txt
index f3a75d1ce1..f970196bc1 100644
--- a/Documentation/gitcredentials.txt
+++ b/Documentation/gitcredentials.txt
@@ -101,16 +101,6 @@ $ git help credential-foo
 $ git config --global credential.helper foo
 -------------------------------------------
 
-If there are multiple instances of the `credential.helper` configuration
-variable, each helper will be tried in turn, and may provide a username,
-password, or nothing. Once Git has acquired both a username and a
-password, no more helpers will be tried.
-
-If `credential.helper` is configured to the empty string, this resets
-the helper list to empty (so you may override a helper set by a
-lower-priority config file by configuring the empty-string helper,
-followed by whatever set of helpers you would like).
-
 
 CREDENTIAL CONTEXTS
 -------------------
@@ -162,6 +152,16 @@ helper::
 	shell (so, for example, setting this to `foo --option=bar` will execute
 	`git credential-foo --option=bar` via the shell. See the manual of
 	specific helpers for examples of their use.
++
+If there are multiple instances of the `credential.helper` configuration
+variable, each helper will be tried in turn, and may provide a username,
+password, or nothing. Once Git has acquired both a username and a
+password, no more helpers will be tried.
++
+If `credential.helper` is configured to the empty string, this resets
+the helper list to empty (so you may override a helper set by a
+lower-priority config file by configuring the empty-string helper,
+followed by whatever set of helpers you would like).
 
 username::
 
-- 
2.13.0.rc1.294.g07d810a77f


  reply	other threads:[~2017-05-02  0:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-02  0:05 [PATCH] clone: handle empty config values in -c Jonathan Nieder
2017-05-02  0:08 ` Brandon Williams
2017-05-02  0:21   ` Jonathan Nieder [this message]
2017-05-02  0:26     ` [PATCH] credential doc: make multiple-helper behavior more prominent (Re: [PATCH] clone: handle empty config values in -c) Brandon Williams
2017-05-02  0:30     ` Jonathan Nieder
2017-05-02  3:11       ` Jeff King
2017-05-02  3:07     ` Jeff King
2017-05-02  2:56 ` [PATCH] clone: handle empty config values in -c Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170502002114.GV28740@aiede.svl.corp.google.com \
    --to=jrnieder@gmail.com \
    --cc=bmwill@google.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jonathantanmy@google.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).