git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: How to use git show's "%<(<N>[,trunc|ltrunc|mtrunc])"?

From
G. Sylvie Davies <sylvie@bit-booster.com>
Date
Feb 3, 2017, 04:19 UTC
Message-ID
<CAAj3zPz8wFc_5dRmM=-jMnqp6a7fGtc4XSyU5meF6mO5me47Dw@mail.gmail.com>
In-Reply-To
<CAE1pOi0-8JnnZbdm9vu1RwTU1mXr7dboLC3ito3LcvK9gkNi_A@mail.gmail.com>
On Thu, Feb 2, 2017 at 9:51 AM, Hilco Wijbenga <hilco.wijbenga@gmail.com> wrote:
Show 20 quoted lines
> Hi all,
>
> I'm trying to get the committer date printed in a custom fashion.
> Using "%cI" gets me close:
>
> $ git show --format="%cI | %an" master | head -n 1
> 2017-01-31T17:02:13-08:00 | Hilco Wijbenga
>
> I would like to get rid of the "-08:00" bit at the end of the
> timestamp. According to the "git show" manual I should be able to use
> "%<(<N>[,trunc|ltrunc|mtrunc])" to drop that last part.
>
> $ git show --format="%<(19,trunc)cI | %an" master | head -n 1
> cI | Hilco Wijbenga
>
> Mmm, it seems to be recognized as a valid "something" but it's not
> working as I had expected. :-) I tried several other versions of this
> but no luck. Clearly, I'm misunderstanding the format description. How
> do I get "2017-01-31T17:02:13 | Hilco Wijbenga" to be output?
>
Will this work for you?

$ git show -s --pretty='%cd | %an' --date=format:%FT%R:%S 2017-02-02T10:01:36 | G. Sylvie Davies

I have no idea how portable this might be.  As "git help log" says:
         --date=format:...  feeds the format ...  to your system
strftime. Use --date=format:%c to show the date in your system
locale’s preferred format. See the strftime manual for a complete list
of format placeholders.
- Sylvie
Previous: Hilco WijbengaNext: Hilco Wijbenga
Message 2 of 6 in “How to use git show's "%<(<N>[,trunc|ltrunc|mtrunc])"?”
  1. Hilco WijbengaFeb 2, 2017
  2. G. Sylvie DaviesFeb 3, 2017
  3. Hilco WijbengaFeb 3, 2017
  4. Duy NguyenFeb 3, 2017
  5. Hilco WijbengaFeb 3, 2017
  6. Duy NguyenFeb 4, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.