git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Theodore Ts'o <tytso@mit.edu>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] pretty: add format specifiers: %gr, %gt, %gI, gi
Date: Sun, 10 Jul 2016 02:16:45 -0400	[thread overview]
Message-ID: <20160710061644.GA19640@sigill.intra.peff.net> (raw)
In-Reply-To: <20160710055402.32684-1-tytso@mit.edu>

On Sun, Jul 10, 2016 at 01:54:02AM -0400, Theodore Ts'o wrote:

> Add new format specifiers which allow the printing of reflog
> timestamp.  This allows us to know when operations which change HEAD
> take place (e.g., guilt pop -a, which does the equivalent of a "git
> reset --hard commit"), since using %cr will display when the commit
> was originally made, instead of when HEAD was moved to that commit.

Hrm. You can already get dates like:

  git log --date=relative -g --format=%gd

(or --date=iso, or whatever). But:

  1. It's always branch@{...date...}, not just ...date...

  2. It takes over %gd, so this:

> git log -g --pretty=format:'%Cred%h%Creset %gd %gs %Cgreen(%gr)%Creset %s' --abbrev-commit

can't be done (you cannot show both HEAD@{0} and "5 minutes ago").

So the status quo definitely isn't as flexible as it could be. I'm just
not excited about adding a bunch more obscure two-character codes that
don't even cover all of the possible date formats (I know we have the
same problem for the author/committer timestamps, but we are stuck with
those for historical reasons).

I wonder if a better approach would be:

  1. In the short term, add specific designators for the fields you'd
     want. One for HEAD@{n} that is unaffected by date, as %gd is (or
     even one for the branch-name and one for "n"). And one for the
     reflog date, by itself, in whatever format --date= asked for.

     That would let you do your format above, though it does not let you
     show the reflog date in multiple formats.

  2. In the long term, teach log's pretty formatter to handle less
     obscure syntax, that can include arguments. The pretty-printer in
     for-each-ref can already do "%(authordate:relative)", and accepts
     any date-format that git knows about. We should do the same here.

I dunno. Your patch does not make either of those paths _harder_, and it
is not like there isn't precedent. It just bloats the user-visible
interface with stuff that would later become redundant (but that we
can't get rid of because of backwards compatibility).

-Peff

  reply	other threads:[~2016-07-10  6:20 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-10  5:54 [PATCH] pretty: add format specifiers: %gr, %gt, %gI, gi Theodore Ts'o
2016-07-10  6:16 ` Jeff King [this message]
2016-07-10 14:26   ` Theodore Ts'o
2016-07-10 16:05     ` Duy Nguyen
2016-07-10 23:28       ` Theodore Ts'o
2016-07-11  5:02     ` Jeff King
2016-07-11  5:03       ` [PATCH 1/5] doc/rev-list-options: clarify "commit@{Nth}" for "-g" option Jeff King
2016-07-11  5:04       ` [PATCH 2/5] doc/rev-list-options: explain "-g" output formats Jeff King
2016-07-11  5:05       ` [PATCH 3/5] doc/pretty-formats: describe index/time formats for %gd Jeff King
2016-07-11 16:48         ` Theodore Ts'o
2016-07-12  0:08           ` Jeff King
2016-07-12  2:01             ` Junio C Hamano
2016-07-11  5:06       ` [PATCH 4/5] date: document and test "raw-local" mode Jeff King
2016-07-11 16:50         ` Theodore Ts'o
2016-07-12  0:16           ` Jeff King
2016-07-11  5:07       ` [PATCH 5/5] date: add "unix" format Jeff King
2016-07-11 16:43       ` [PATCH] pretty: add format specifiers: %gr, %gt, %gI, gi Theodore Ts'o
2016-07-11 19:07         ` 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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160710061644.GA19640@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=tytso@mit.edu \
    /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.
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 NNTP newsgroup(s).