git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: "brian m. carlson" <sandals@crustytoothpaste.net>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>,
	Christian Couder <christian.couder@gmail.com>,
	Taylor Blau <me@ttaylorr.com>
Subject: Re: [PATCH v2] rev-list: add option for --pretty=format without header
Date: Mon, 12 Jul 2021 14:13:54 -0400	[thread overview]
Message-ID: <YOyGYs+uDr7tYxON@coredump.intra.peff.net> (raw)
In-Reply-To: <20210711215510.191626-1-sandals@crustytoothpaste.net>

On Sun, Jul 11, 2021 at 09:55:10PM +0000, brian m. carlson wrote:

> In general, we encourage users to use plumbing commands, like git
> rev-list, over porcelain commands, like git log, when scripting.
> However, git rev-list has one glaring problem that prevents it from
> being used in certain cases: when --pretty is used with a custom format,
> it always prints out a line containing "commit" and the object ID.  This
> makes it unsuitable for many scripting needs, and forces users to use
> git log instead.
> 
> While we can't change this behavior for backwards compatibility, we can
> add an option to suppress this behavior, so let's do so, and call it
> "--no-commit-header".  Additionally, add the corresponding positive
> option to switch it back on.
> 
> Note that this option doesn't affect the built-in formats, only custom
> formats.  This is exactly the same behavior as users already have from
> git log and is what most users will be used to.

Thanks for working on this. It has bugged me for at least a decade. :)

I do wish this had been made the default when we introduced
--pretty=format, but I agree we can't just change it now. This could be
something to keep in mind for future deprecation (or a large breaking
version). People would have to start saying --commit-header now to
future-proof themselves if they really want the current behavior. I'm OK
to leave any plans / warnings like that for future work.

The patch looks correct to me. I did have one small nit:

> diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt
> index 5bf2a85f69..23388f36c3 100644
> --- a/Documentation/rev-list-options.txt
> +++ b/Documentation/rev-list-options.txt
> @@ -1064,6 +1064,14 @@ ifdef::git-rev-list[]
>  --header::
>  	Print the contents of the commit in raw-format; each record is
>  	separated with a NUL character.
> +
> +--no-commit-header::
> +	Suppress the header line containing "commit" and the object ID printed before
> +	the specified format.  This has no effect on the built-in formats; only custom
> +	formats are affected.

It wasn't immediately obvious to me what "custom formats" meant here. I
don't think we use that term elsewhere, nor do we seem to have a
succinct phrase for the concept. Maybe something like:

  only custom formats (i.e., `--pretty=format:`) are affected.

helps without making it too clunky?

-Peff

  parent reply	other threads:[~2021-07-12 18:14 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-06 22:43 [PATCH] rev-list: add option for --pretty without header brian m. carlson
2021-07-09  8:01 ` Christian Couder
2021-07-09 15:44   ` Junio C Hamano
2021-07-11 17:02     ` brian m. carlson
2021-07-11 21:55 ` [PATCH v2] rev-list: add option for --pretty=format " brian m. carlson
2021-07-12  7:30   ` Christian Couder
2021-07-13  0:10     ` brian m. carlson
2021-07-12 18:13   ` Jeff King [this message]
2021-07-13  0:15     ` brian m. carlson

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=YOyGYs+uDr7tYxON@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=me@ttaylorr.com \
    --cc=sandals@crustytoothpaste.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).