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: 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: Tue, 8 Sep 2020 09:53:03 -0400	[thread overview]
Message-ID: <20200908135303.GA2448968@coredump.intra.peff.net> (raw)
In-Reply-To: <xmqqtuwa13gt.fsf@gitster.c.googlers.com>

On Sun, Sep 06, 2020 at 11:54:42PM -0700, Junio C Hamano wrote:

> > I gave a reason for the reference format, at least.
> >
> > Would you be fine with a patch that just allows to override the
> > reference format (for the stated reasons)?
> 
> Your "reason" read pretty much the same as "I want reference to do
> something else", but that leads to "depending on the configuration,
> even built-in names that are well known to all Git users behave
> differently---the users lose common reference (no pun intended)".

I think there is some value in having names and rough semantics that are
well-known to all Git users (and scripts), but whose exact output is not
set in stone.  So a name like "reference" becomes a rendezvous point
between a script like gitk and the user. It is a shorthand for
"reference a commit in a human-readable way according to the user or
project preferences". The script wants to read that value, and the user
wants to specify it.

You could accomplish something similar by having gitk look up
pretty.userReference, and defaulting to something sensible if it's not
defined. For a big script like gitk that's not too much of an
imposition. But it's awfully convenient to be able to just say
--format=reference in any script and get the user's preferred format.

That's where I think your pretty.kernel example falls down; both the
repo and the script have to agree that the name "kernel" exists.

> Also I am not sure how your reason applies specifically to the
> reference format.  It would be widely applicable to other formats
> like 'short' and 'oneline' in that depending on projects' and
> personal preference, people may want "something like X but not
> exactly X" for all the built-in formats.

The things that may make "reference" different are:

 - it's new-ish, so there's less chance of historical dependencies on it
   (this is a bit hand-wavy, of course; it has been in released
   versions. On the other hand, people may well have been using
   pretty.reference for this already, and we made it stop working when
   we added "reference").

 - from the start, the point was for it to be a human-readable format
   (it's not even unambiguously parseable anyway).

So of any of the formats, it seems like the most likely candidate for
such a feature (setting "pretty.raw" would be a pretty big foot-gun, for
instance). I don't like the inconsistency it introduces between formats,
though.

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

? That would let pretty.reference override the built-in name, but the
behavior of plain "--format=reference" would continue to ignore it. It's
a little more annoying for a script to specify, but not nearly as
annoying as:

  format=$(git config pretty.customReference || echo "%h (%s, %d)")
  git log --format="%format"

-Peff

  parent reply	other threads:[~2020-09-08 16:40 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 [this message]
2020-09-08 18:12           ` Junio C Hamano
2020-09-09  9:08             ` Jeff King
2020-09-09 18:27               ` Junio C Hamano

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=20200908135303.GA2448968@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=dev+git@drbeat.li \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=liu.denton@gmail.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).