git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Beat Bolli <dev+git@drbeat.li>, Denton Liu <liu.denton@gmail.com>,
	git@vger.kernel.org
Subject: Re: [PATCH] pretty: allow to override the built-in formats
Date: Wed, 09 Sep 2020 11:27:43 -0700	[thread overview]
Message-ID: <xmqqtuw6vm8w.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <20200909090842.GA2496536@coredump.intra.peff.net> (Jeff King's message of "Wed, 9 Sep 2020 05:08:42 -0400")

Jeff King <peff@peff.net> writes:

> On Tue, Sep 08, 2020 at 11:12:11AM -0700, Junio C Hamano wrote:
>
>> > Here's a slightly different proposal. I'm not sure if I like it or not,
>> > but just thinking out loud for a moment. The issue is that we're worried
>> > the consumer of the output may be surprised by a user-configured pretty
>> > format. Can we give them a way to say "I don't care about the exact
>> > output; pick what the user configured for this name, or some sane
>> > default". I.e., something like:
>> >
>> >   git log --format=loose:reference
>> 
>> Yeah, that, or with s/loose/user/ or something.
>
> Heh, I actually called it "user:" initially but wasn't sure if that was
> sufficiently descriptive, so I groped around for another word. But if
> both of us thought of "user", maybe it's better.
>
> At any rate, this was mostly just thinking out loud, and isn't something
> I'm planning to follow up on with a patch. But maybe it inspires
> somebody to run with it.

Of course, we could go the other way and follow the same approach as
the "--literal-pathspecs" feature (and what bash does with the alias
and uses "command" keyword to work around the confusion it causes).

IOW, we could force those scripts that want to be strict to pay the
price and be explicit (e.g. "--format=builtin:<name>") and allow
others that want to be affected by end user customization can keep
saying "--format=<name>".  It unfortunately breaks our long standing
stance against backward compatibility breaking changes, so I would
say it is not likely to happen.  "--format=loose:reference" does not
share the problem, and it is much safer.

In any case, I do not think "pretty.override<word>" configuration
variable, which warns with the 'override' and makes those who tweak
builtin format think twice, is a good idea.  Those who add the
custom configuration are not in the position to decide if a
particular use of --format=<word> in a script (like gitk[*1*]) should
or should not be affected by customization.  It is up to the script
writers [*2*].


[Footnote]

*1* We've been using gitk as an example but it is not the best one,
    since it was made crystal clear that gitk will not be accepting a
    single liner patch that uses --pretty=reference anyway, it is a
    moot point.

    cf. https://lore.kernel.org/git/20191211215826.GA31614@blackberry/

*2* In general, a script wants strict/builtin output if it captures
    and parses, and customizable output if it just lets the git
    command it calls directly talk to the end user.

      reply	other threads:[~2020-09-09 18:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-05 19:24 [PATCH] pretty: allow to override the built-in formats Beat Bolli
2020-09-05 19:52 ` Denton Liu
2020-09-06 21:59   ` Junio C Hamano
2020-09-07  5:36     ` Beat Bolli
2020-09-07  6:54       ` Junio C Hamano
2020-09-07  7:06         ` Beat Bolli
2020-09-08 13:53         ` Jeff King
2020-09-08 18:12           ` Junio C Hamano
2020-09-09  9:08             ` Jeff King
2020-09-09 18:27               ` Junio C Hamano [this message]

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=xmqqtuw6vm8w.fsf@gitster.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=dev+git@drbeat.li \
    --cc=git@vger.kernel.org \
    --cc=liu.denton@gmail.com \
    --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.
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).