From: Jeff King <peff@peff.net>
To: Daniel Lo <wilburlo@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Request for examples on git log --format:tformat
Date: Sat, 29 Sep 2018 03:56:38 -0400 [thread overview]
Message-ID: <20180929075638.GG2174@sigill.intra.peff.net> (raw)
In-Reply-To: <CAOeX3KXASgnyVcZuTAjyXLgnZpeA1FD3XXvSoRd11b9V9jpGFg@mail.gmail.com>
On Fri, Sep 28, 2018 at 11:29:32AM -0700, Daniel Lo wrote:
> I was reviewing the tformat parameters on:
> https://git-scm.com/docs/git-log (middle of the page).
>
> Specifically: %<|(<N>): make the next placeholder take at least until
> Nth columns, padding spaces on the right if necessary
>
> I found the instructions regard space formatting to be very confusing.
> An example would be helpful to illustrate what the proper space
> formatting syntax is:
>
> Ex:
> git log --format="tformat:%h %<(15)%an %s"
>
> 0123456 Author Name Commit message - author name is formatted to be
> padded with space to occupy at least 15 characters
>
> All of the special symbols %<|(<>) made me confused to what was
> required and what was describing the syntax.
I'm not sure if you're asking for somebody to give an example here, or
suggesting that the documentation should contain an example.
If the former, then an example matching the documentation you quoted is:
git log --format='%h %<|(15)%an %s'
The difference (I think -- I've never actually use either of these in
the wild myself) between %< and %<| is that the former pads out to N
spaces, and the latter pads out until we've reached the Nth column (so
taking into account all prior content on the line, too).
To see the difference try:
# pad names to 30 chars
git log --format='%h %<(30)%an %s'
versus
# pad out to the 30th column, including the hash
git log --format='%h %<|(30)%an %s'
versus
# pad out to the 30th column, but without the hash there should be
# much more whitespace
git log --format='%<|(30)%an %s'
If you are suggesting that there should be some examples in the
documentation, I agree (I had to stare at the descriptions and run a few
tests myself to figure this out). I'm not sure if they should go near
the placeholder list, or in the examples section.
-Peff
PS Orthogonal to your question, but one tip: "--format" defaults to
"tformat:" if its argument contains %-placeholders.
prev parent reply other threads:[~2018-09-29 7:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-28 18:29 Request for examples on git log --format:tformat Daniel Lo
2018-09-29 7:56 ` Jeff King [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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180929075638.GG2174@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=wilburlo@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.
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).