Skip to content

Commit dbe80f9

Browse files
peffgitster
authored andcommitted
gitcredentials(7): clarify quoting of helper examples
We give several helper config examples, but don't make clear that these are raw values. It's up to the user to add the appropriate quoting to put them into a config file (either by running with "git config" and quoting against the shell, or by adding double-quotes as appropriate within the git-config file). Let's flesh them out as full config blocks, which makes the syntax more clear (and makes it possible for people to just cut-and-paste them as a starting point). I added double-quotes to any values larger than a single word. That isn't strictly necessary in all cases, but it sidesteps explaining the rules about exactly when you need to quote a value. The existing quotes can be converted to single-quotes in one instance, and backslash-esccaped in the other. I also swapped out backticks for our preferred $(). Reported-by: [email protected] Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent af6b65d commit dbe80f9

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

Documentation/gitcredentials.txt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,20 +216,25 @@ Here are some example specifications:
216216

217217
----------------------------------------------------
218218
# run "git credential-foo"
219-
foo
219+
[credential]
220+
helper = foo
220221

221222
# same as above, but pass an argument to the helper
222-
foo --bar=baz
223+
[credential]
224+
helper = "foo --bar=baz"
223225

224226
# the arguments are parsed by the shell, so use shell
225227
# quoting if necessary
226-
foo --bar="whitespace arg"
228+
[credential]
229+
helper = "foo --bar='whitespace arg'"
227230

228231
# you can also use an absolute path, which will not use the git wrapper
229-
/path/to/my/helper --with-arguments
232+
[credential]
233+
helper = "/path/to/my/helper --with-arguments"
230234

231235
# or you can specify your own shell snippet
232-
!f() { echo "password=`cat $HOME/.secret`"; }; f
236+
[credential]
237+
helper = "!f() { echo \"password=$(cat $HOME/.secret)\"; }; f"
233238
----------------------------------------------------
234239

235240
Generally speaking, rule (3) above is the simplest for users to specify.

0 commit comments

Comments
 (0)