@matheusbsbs / matheus-bagliano / commits / dbe80f928c
Fork 0

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: douglas.fuller@gmail.com Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed May 1, 2020 at 03:33 UTC dbe80f928c762db21bb19d6969a804d437978741
1 file changed +10 -5
Documentation/gitcredentials.txt
+10 -5
@@ -216,20 +216,25 @@ Here are some example specifications:
216
217 ----------------------------------------------------
218 # run "git credential-foo"
219 -foo
219 +[credential]
220 + helper = foo
221
222 # same as above, but pass an argument to the helper
222 -foo --bar=baz
223 +[credential]
224 + helper = "foo --bar=baz"
225
226 # the arguments are parsed by the shell, so use shell
227 # quoting if necessary
226 -foo --bar="whitespace arg"
228 +[credential]
229 + helper = "foo --bar='whitespace arg'"
230
231 # 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"
234
235 # 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"
238 ----------------------------------------------------
239
240 Generally speaking, rule (3) above is the simplest for users to specify.