git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] gitcredentials(7): make shell-snippet example more realistic

From
Jeff King <peff@peff.net>
Date
May 1, 2020, 06:23 UTC
Message-ID
<20200501062316.GB25603@coredump.intra.peff.net>
In-Reply-To
<20200501061917.GC23665@coredump.intra.peff.net>

There's an example of using your own bit of shell to act as a credential helper, but it's not very realistic:

 - It's stupid to hand out your secret password to _every_ host. In the
   real world you'd use the config-matcher to limit it to a particular
   host.
 - We never provided a username. We can easily do that in another config
   option (you can do it in the helper, too, but this is much more
   readable).
 - We were sending the secret even for store/erase operations. This
   is OK because Git would just ignore it, but a real system would
   probably be unlocking a password store, which you wouldn't want to do
   more than necessary.
Signed-off-by: Jeff King <peff@peff.net>
---
This is in fact very close to what's in my own ~/.gitconfig, except that
I swap out "cat" for the "pass" tool.
 Documentation/gitcredentials.txt | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/Documentation/gitcredentials.txt b/Documentation/gitcredentials.txt
index 8a20343dd7..63b20fc6a5 100644
--- a/Documentation/gitcredentials.txt
+++ b/Documentation/gitcredentials.txt
@@ -233,8 +233,9 @@ helper = "foo --bar='whitespace arg'"
 helper = "/path/to/my/helper --with-arguments"
 
 # or you can specify your own shell snippet
-[credential]
-helper = "!f() { echo password=$(cat $HOME/.secret); }; f"
+[credential "https://example.com"]
+username = your_user
+helper = "!f() { test $1 = get && echo password=$(cat $HOME/.secret); }; f"
 ----------------------------------------------------
 
 Generally speaking, rule (3) above is the simplest for users to specify.
-- 
2.26.2.933.gdf62622942
Previous: Jeff KingNext: Junio C Hamano
Message 8 of 18 in “doc: fix quoting bug in credential cache example”
  1. doc: fix quoting bug in credential cache exampledouglas.fuller@gmail.com, Apr 30, 2020
  2. Junio C HamanoApr 30, 2020
  3. Jeff KingMay 1, 2020
  4. Jeff KingMay 1, 2020
  5. 1/2 gitcredentials(7): clarify quoting of helper examplesJeff King, May 1, 2020
  6. Andreas SchwabMay 1, 2020
  7. Jeff KingMay 1, 2020
  8. 2/2 gitcredentials(7): make shell-snippet example more realisticJeff King, May 1, 2020
  9. Junio C HamanoMay 1, 2020
  10. Jeff KingMay 1, 2020
  11. Jeff KingMay 1, 2020
  12. Jeff KingMay 1, 2020
  13. 1/2 gitcredentials(7): clarify quoting of helper examplesJeff King, May 1, 2020
  14. 2/2 gitcredentials(7): make shell-snippet example more realisticJeff King, May 1, 2020
  15. Junio C HamanoMay 1, 2020
  16. douglas.fuller@gmail.comMay 1, 2020
  17. Junio C HamanoMay 1, 2020
  18. Jeff KingMay 1, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.