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

Re: --no-decorate and %d in git-log(1)

From
ACAlejandro Colomar <alx@kernel.org>
Date
Feb 25, 2026, 21:54 UTC
Message-ID
<aZ9vBfhiaR7gO9hs@devuan>
In-Reply-To
<cf3d274e-7363-4557-809a-a649b1d304ad@xiplink.com>
Hi Junio, Marc,
On 2026-02-25T14:46:10-0700, Marc Branchaud wrote:
Show 60 quoted lines
> 
> On 2026-02-25 13:08, Junio C Hamano wrote:
> > Marc Branchaud <marcnarc@xiplink.com> writes:
> > 
> > > BTW, --decorate=auto is documented as "if the output is going to a
> > > terminal, the ref names are shown as if `short` were given, otherwise no
> > > ref names are shown."  But in my experiments %d still shows refs even
> > > when the output is piped to a file.  Seems like another symptom of the
> > > same bug?
> > 
> > Isn't that documentation merely referring to "git log" without
> > "--format=... %d ..." and not about the case where you explicitly
> > ask for "%d"?  That is, the description is there to explain the
> > differences between
> > 
> > 	git log --oneline --decorate=auto -1
> > 	git log --oneline --decorate=auto -1 | cat
> > 
> > isn't it?
> 
> I'm sure that's how the code works, but I don't see any indication in the
> documentation that this is for when --format isn't used or when the format
> doesn't contain %d.  The descriptions of --decorate and --format mostly just
> ignore each other.
> 
> We do have this at the end of the --format section:
> 
> 	The %d and %D placeholders will use the "short"
> 	decoration format if --decorate was not already
> 	provided on the command line.
> 
> Given this documented connection between %d/%D and --decorate, it seems
> reasonable for a reader to assume that --decorate=auto would do the same
> thing regardless of whether or not a --format=...%d... was present.
> 
> > I think --decorate=auto is the default so the above
> > without --decorate=auto would behave similarly.
> > 
> > > (Do people who use `--format` (with or without %d) *also* use
> > > `--decorate`?  It seems like the two are naturally exclusive, even if
> > > the code allows them both.)
> > 
> > That is an interesting question, but I am not sure if it affects how
> > we decide to resolve this discussion.
> 
> Yeah, it's more philosophical, though if we did know the answer was "the two
> are almost never used together" we'd be more comfortable changing how
> --decorate=no and --format=%d interact.
> 
> I note that currently --decorate has no effect at all if the --format
> doesn't contain %d or %D.  To me this bolsters the argument for making
> --decorate=no suppress %d/%D.
> 
> 
> To expand on my earlier point: --decorate=no currently has the same effect
> on %d/%D as --decorate=short, so it seems to me that we can change what
> --decorate=no does because if anyone needs to preserve the existing behavior
> for their favorite --format they can just use --decorate=short.  (I'd be
> surprised if anyone is using --decorate=no to ensure that they get the short
> ref names).

I agree with this. If anyone has a script, I expect it won't use both --decorate=no and %d together, because it makes no sense (at least with the current behavior). And if there's some case where they do it for some reason, they're able to change =no to =short to keep the old behavior.

Cheers, Alex

> 
> 		M.
> 
-- 
<https://www.alejandro-colomar.es>
Previous: Marc BranchaudNext: Junio C Hamano
Message 8 of 9 in “--no-decorate and %d in git-log(1)”
  1. Alejandro ColomarFeb 25, 2026
  2. Junio C HamanoFeb 25, 2026
  3. Alejandro ColomarFeb 25, 2026
  4. Junio C HamanoFeb 25, 2026
  5. Marc BranchaudFeb 25, 2026
  6. Junio C HamanoFeb 25, 2026
  7. Marc BranchaudFeb 25, 2026
  8. Alejandro ColomarFeb 25, 2026
  9. Junio C HamanoMar 1, 2026

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.