From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: douglas.fuller@gmail.com, git@vger.kernel.org
Subject: Re: [PATCH 2/2] gitcredentials(7): make shell-snippet example more realistic
Date: Fri, 01 May 2020 08:11:35 -0700 [thread overview]
Message-ID: <xmqqr1w3ofko.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <20200501063513.GB26128@coredump.intra.peff.net> (Jeff King's message of "Fri, 1 May 2020 02:35:13 -0400")
Jeff King <peff@peff.net> writes:
>> I can add back in the quoted \", though it does make the code slightly
>> harder to read.
>
> Or did you mean passing $1 in the test call? It definitely isn't good
> shell practice, but we know that we're getting a single-word action from
> Git, per the protocol.
I meant former. I actually am having a second thought.
I do not think this page should be the canonical place for config
and shell syntax lessons, but the value we have been using as an
example is a good candidate that an end user would encounter in the
real life and has need to do so.
Perhaps it deserves some comment next to it?
; For the specified site, use "your_user" as the username, and
; invoke the helper, which is a short shell script. Note that the
; value of the helper variable is enclosed in a double-quote pair,
; because it has a semicolon, which will cause the rest of the line
; discarded as a comment unless quoted. The shell script in turn
; needs to quote various pieces of it in double quotes, each of
; which needs to be escaped with a backslash.
[credential "https://example.com"]
username = your_user
helper = "!f() { test \"$1\" = get && echo \"password=$(cat $HOME/.secret)\"; }; f"
The more I think about it, the worse it becomes X-<
Do we expect that most of our users are comfortable editing
~/.gitconfig in their editor, or do they mostly work with the "git
config --global" command?
I have a feeling that my wishful-thinking answer, which is "former",
is not true in the real world. Which means they not only need to
quote for the parser of the configuration file, but they then need
to quote that for the shell X-<.
$ git config --global credential.https://example.com.helper \
'"!f() { test \"$1\" = get && echo \"password=$(cat $HOME/.secret)\"; }; f"'
I wonder if it helps the users to have something that guides them to
figure out how they do the above.
> Fully quoting, it looks like this:
>
> helper = "!f() { test \"$1\" = get && echo \"password=$(cat $HOME/.secret)\"; }; f"
>
> which IMHO is getting a little hard to read. I think that's part of why
> I gave such an unfinished example in the first place. :)
Yes, "these are values, go quote them as necessary" is certainly a
lot more attractive position to take. But apparently that wasn't
all that helpful.
Thanks.
next prev parent reply other threads:[~2020-05-01 15:11 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-30 14:36 [PATCH] doc: fix quoting bug in credential cache example douglas.fuller
2020-04-30 18:09 ` Junio C Hamano
2020-05-01 5:57 ` Jeff King
2020-05-01 6:19 ` Jeff King
2020-05-01 6:20 ` [PATCH 1/2] gitcredentials(7): clarify quoting of helper examples Jeff King
2020-05-01 7:19 ` Andreas Schwab
2020-05-01 7:31 ` Jeff King
2020-05-01 6:23 ` [PATCH 2/2] gitcredentials(7): make shell-snippet example more realistic Jeff King
2020-05-01 6:26 ` Junio C Hamano
2020-05-01 6:32 ` Jeff King
2020-05-01 6:35 ` Jeff King
2020-05-01 7:32 ` Jeff King
2020-05-01 7:33 ` [PATCH v2 1/2] gitcredentials(7): clarify quoting of helper examples Jeff King
2020-05-01 7:33 ` [PATCH v2 2/2] gitcredentials(7): make shell-snippet example more realistic Jeff King
2020-05-01 15:11 ` Junio C Hamano [this message]
2020-05-01 14:40 ` [PATCH] doc: fix quoting bug in credential cache example douglas.fuller
2020-05-01 6:20 ` Junio C Hamano
2020-05-01 6:25 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqr1w3ofko.fsf@gitster.c.googlers.com \
--to=gitster@pobox.com \
--cc=douglas.fuller@gmail.com \
--cc=git@vger.kernel.org \
--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.
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 NNTP newsgroup(s).