git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	git@vger.kernel.org, "The Grey Wolf" <greywolf@starwolf.com>,
	"Randall S . Becker" <rsbecker@nexbridge.com>
Subject: Re: [PATCH] config: add an includeIf.env{Exists,Bool,Is,Match}
Date: Mon, 27 Sep 2021 16:15:52 -0400	[thread overview]
Message-ID: <YVImeFHxY7hmb3wY@coredump.intra.peff.net> (raw)
In-Reply-To: <xmqqo88eq8um.fsf@gitster.g>

On Mon, Sep 27, 2021 at 09:30:41AM -0700, Junio C Hamano wrote:

> >> This asserts what? FOO=" bar"?
> >
> > Whoops, that should have been "envIs", asserting that $FOO contains
> > "bar".
> 
> Oh, "can we check with a literal with leading whitespace?" was what
> my question was about ;-)

My assumption was that nobody would really care about doing so. It is
true that it's less flexible, though (and is a decision we can't easily
take back later).

> > As I said, I think it matters more with the infix operators, as:
> >
> >   [includeIf "env:FOO == bar"]
> >
> > is more readable than:
> >
> >   [includeIf "env:FOO==bar"]
> 
> Sure, but at that point, we'd probably want some quoting mechanism
> for the literal to be compared, e.g.
> 
> 	[includeIf "env:PATH ~= \"(:|^)/usr/bin(:|$)\""]

Ick. The extra quoting of the internal double-quotes is pretty horrid to
look at. Also, how does one match a double-quote in the value? \\\"?

If it were optional, that would make the common cases easy (no dq, no
whitespace), and the hard ones possible.

I think this is getting into a bit of a digression, though. I'm willing
to defer to Ævar, who is doing the actual work, and I don't know if he
has found any of this compelling. ;)

> > But I do think:
> >
> >   [includeIf "envIs:FOO:bar"]
> >
> > is harder to read than even:
> >
> >   [includeIf "envIs:FOO: bar"]
> 
> Hmph, that's quite subjective, I am afraid.  When I see the latter
> in the configuration file, "do I have to have a single space before
> 'bar' in the value of $FOO" would be the first question that would
> come to my mind.

I think it's just the mashed-up colons that I find ugly in the first
one. But I agree the latter isn't that nice either, and introduces the
ambiguity you describe.

> With an understanding that our syntax is so limited that we cannot
> even write '=' and need to resort to Is: instead, I'd actually find
> that the former less confusing than the latter.

That I think is the most interesting question: is the "=" actually
out-of-bounds? I tend to think not, based on our responses earlier in
the thread.

-Peff

  reply	other threads:[~2021-09-27 20:15 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-23  5:21 ANSI sequences produced on non-ANSI terminal The Grey Wolf
2021-09-23 21:20 ` Jeff King
2021-09-23 21:54   ` Junio C Hamano
2021-09-23 22:04     ` Randall S. Becker
2021-09-25  6:45       ` Kevin Daudt
2021-09-24  0:58   ` [PATCH] config: add an includeIf.env{Exists,Bool,Is,Match} Ævar Arnfjörð Bjarmason
2021-09-24 21:07     ` Jeff King
2021-09-24 21:28       ` Junio C Hamano
2021-09-24 21:59         ` Jeff King
2021-09-27 16:30           ` Junio C Hamano
2021-09-27 20:15             ` Jeff King [this message]
2021-09-27 20:53               ` Randall S. Becker
2021-09-27 21:37                 ` Jeff King
2021-09-27 21:56                   ` Randall S. Becker
2021-09-27 23:52               ` Ævar Arnfjörð Bjarmason
2021-09-28  0:41                 ` Jeff King
2021-09-28  2:42                   ` Ævar Arnfjörð Bjarmason
2021-09-28  5:42                     ` Jeff King
2021-09-28 19:28                       ` Ævar Arnfjörð Bjarmason
2021-09-28  0:24               ` Junio C Hamano
2021-09-24 23:57   ` ANSI sequences produced on non-ANSI terminal Greywolf
2021-09-25  5:49     ` Jeff King
2021-10-01 23:17       ` Greywolf

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 \
    --in-reply-to=YVImeFHxY7hmb3wY@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=greywolf@starwolf.com \
    --cc=rsbecker@nexbridge.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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).