From: "Ævar Arnfjörð Bjarmason" <firstname.lastname@example.org> To: Jeff King <email@example.com> Cc: Junio C Hamano <firstname.lastname@example.org>, Patrick Steinhardt <email@example.com>, firstname.lastname@example.org Subject: Re: [PATCH 2/2] config: allow specifying config entries via envvar pairs Date: Wed, 18 Nov 2020 14:44:59 +0100 Message-ID: <email@example.com> (raw) In-Reply-To: <20201117235736.GC642410@coredump.intra.peff.net> On Wed, Nov 18 2020, Jeff King wrote: > On Tue, Nov 17, 2020 at 03:22:05PM +0100, Ævar Arnfjörð Bjarmason wrote: > >> > then I'd feel comfortable making it a public-facing feature. And for >> > most cases it would be pretty pleasant to use (and for the unpleasant >> > ones, I'm not sure that a little quoting is any worse than the paired >> > environment variables found here). >> >> I wonder if something like the git config -z format wouldn't be easier, >> with the twist that we'd obviously not support \0. So we'd need an >> optional length prefix. : = unspecified. >> >> :user.name >> Jeff K >> :alias.ci >> commit >> :10:bin.ary >> <10 byte string, might have a \n> >> :other.key >> Other Value >> >> Maybe that's overly fragile, or maybe another format would be better. > > Yeah, length-delimited strings are an alternative that some people think > is less error-prone than quoting. And we do use pkt-lines. They're also > a pain for humans to write (it's nicer if they're optional, but when you > _do_ have to start using them, now you are stuck counting things up). > >> I was trying to come up with one where the common case wouldn't >> require knowing about shell quoting/unquoting, and where you could >> still do: >> >> GIT_CONFIG_PARAMETERS=":my.new\nvalue\n$GIT_CONFIG_PARAMETERS" >> >> Or equivalent, and still just keep $GIT_CONFIG_PARAMETERS as-is to pass >> it along. >> >> Your "do not require quoting" accomplishes that, and it's arguably a lot >n > Looks like your mail got cut off. Nothing important, probably :) > But yeah, the goal of making the quoting optional was to make it > easier for humans to use for simple cases. It doesn't help at all with > other programs inserting values, which can just as easily err on the > side of caution. > > BTW, there is another problem with GIT_CONFIG_PARAMETERS (and "git -c" > in general). The dotted config-key format: > > section.subsection.key > > is unambiguous by itself, even though "subsection" can contain arbitrary > bytes, including dots. Because neither "section" nor "key" can contain > dots, we can parse from either end, and take the whole middle as a > subsection (and this is how we do it in the code). > > But an assignment string like: > > section.subsection.key=value > > _is_ ambiguous. We have to parse left-to-right up to the first equals > (since "value" can contain arbitrary characters, including an equals). > But "subsection" can have one, too, so we want to parse right-to-left > there. E.g., in: > > one.two=three.four=five > > this could be either of: > > - section is "one", key is "two", value is "three.four=five" > > - section is "one", subsection is "two=three", key is "four", value is > "five" > > We currently always parse it as the former (which I think is least-bad > of the two, since values are more likely than subsections to contain > arbitrary text with an equals). Yeah, it's a pain to parse if it's on one line. FWIW that's the main reason for why the format I suggested moved it to \n-delimited, because keys can't contain an \n, so you can unambiguously have them be \n-delimited (as git config -z does). You do need to worry about a \n in the value, but for the common case where you don't have a \n there we wouldn't need to provide the length. Or just provide tooling as you suggested in <20201118015907.GD650959@coredump.intra.peff.net>, which I like better than any one format suggestion (including the one I suggsted). I.e. we can document that: - The variable exists - You read/write/add to it using a return value from this tool Which allows for keeping the value itself opaque and open to a future change.
next prev parent reply other threads:[~2020-11-18 13:46 UTC|newest] Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-11-13 12:16 [PATCH 0/2] " Patrick Steinhardt 2020-11-13 12:16 ` [PATCH 1/2] config: extract function to parse config pairs Patrick Steinhardt 2020-11-13 12:16 ` [PATCH 2/2] config: allow specifying config entries via envvar pairs Patrick Steinhardt 2020-11-13 13:04 ` Ævar Arnfjörð Bjarmason 2020-11-16 19:39 ` Junio C Hamano 2020-11-17 2:34 ` Jeff King 2020-11-17 6:37 ` Patrick Steinhardt 2020-11-17 7:01 ` Jeff King 2020-11-17 14:22 ` Ævar Arnfjörð Bjarmason 2020-11-17 23:57 ` Jeff King 2020-11-18 13:44 ` Ævar Arnfjörð Bjarmason [this message] 2020-11-18 0:50 ` brian m. carlson 2020-11-18 1:59 ` Jeff King 2020-11-18 2:25 ` brian m. carlson 2020-11-18 7:04 ` Patrick Steinhardt 2020-11-19 2:11 ` brian m. carlson 2020-11-19 6:37 ` Patrick Steinhardt 2020-11-18 5:44 ` Junio C Hamano 2020-11-17 6:28 ` Patrick Steinhardt 2020-11-17 7:06 ` Junio C Hamano 2020-11-18 13:49 ` Ævar Arnfjörð Bjarmason 2020-11-18 13:56 ` Patrick Steinhardt 2020-11-18 16:01 ` Junio C Hamano 2020-11-17 14:03 ` Ævar Arnfjörð Bjarmason 2020-11-13 16:37 ` Philip Oakley 2020-11-17 6:40 ` Patrick Steinhardt 2020-11-13 13:11 ` [PATCH 0/2] " Ævar Arnfjörð Bjarmason
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 \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ /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
firstname.lastname@example.org list mirror (unofficial, one of many) This inbox may be cloned and mirrored by anyone: git clone --mirror https://public-inbox.org/git git clone --mirror http://ou63pmih66umazou.onion/git git clone --mirror http://czquwvybam4bgbro.onion/git git clone --mirror http://hjrcffqmbrq6wope.onion/git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V1 git git/ https://public-inbox.org/git \ email@example.com public-inbox-index git Example config snippet for mirrors. Newsgroups are available over NNTP: nntp://news.public-inbox.org/inbox.comp.version-control.git nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git nntp://news.gmane.io/gmane.comp.version-control.git note: .onion URLs require Tor: https://www.torproject.org/ code repositories for the project(s) associated with this inbox: https://80x24.org/mirrors/git.git AGPL code for this site: git clone https://public-inbox.org/public-inbox.git