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

Question about 'git log', custom formats, and '--left-right' and friends

From
Philippe Blain <levraiphilippeblain@gmail.com>
Date
Jan 20, 2021, 03:40 UTC
Message-ID
<24504597-7c14-70aa-393b-2e18df2a51bb@gmail.com>
Hi everyone,

I think I've come across a limitation of using custom pretty formats along with the '--left-right', '--boundary', '--cherry-mark' options to 'git log'.

I'm trying to replicate the behaviour of the 'oneline' pretty format when it is used with or without the options above and a symmetric difference. When not using any of the options above, no mark is added before the commit hash in non-graph mode, and a '*' is added in graph-mode. When using the options above, the corresponding marks are used: '>', '<', for left/right, '-' for boundary ('o' in graph mode), '+' and '=' for cherry-mark, etc.

I'd like to get this behaviour with a custom pretty format (I use it to add some more informations to what '--oneline' shows), but it seems it is not possible. And the '%m' placeholder does not help a lot, as it's 'always on'. The script below demonstrates what I'm talking about:

~~~ #!/bin/sh

run () { echo echo "RUNNING: $@" "$@" }

rm -rf test mkdir test cd test

git init -b master remote echo data>remote/file && git -C remote add file && git -C remote commit -m root git clone remote clone echo dato>remote/file && git -C remote add file && git -C remote commit -m L echo date>clone/file && git -C clone add file && git -C clone commit -m R git -C clone fetch git -C clone config pretty.ol '%h %s' git -C clone config pretty.ol2 '%m %h %s'

run git -C clone log --oneline --no-decorate --left-right @{u}... run git -C clone log --format=ol --left-right @{u}... run git -C clone log --format=ol2 --left-right @{u}...

run git -C clone log --graph --oneline --no-decorate --left-right @{u}... run git -C clone log --graph --format=ol --left-right @{u}... run git -C clone log --graph --format=ol2 --left-right @{u}...

run git -C clone log --oneline --no-decorate @{u}... run git -C clone log --format=ol @{u}... run git -C clone log --format=ol2 @{u}...

run git -C clone log --graph --oneline --no-decorate @{u}... run git -C clone log --graph --format=ol @{u}... run git -C clone log --graph --format=ol2 @{u}... ~~~

the (commented) output looks like:
---
RUNNING: git -C clone log --oneline --no-decorate --left-right @{u}...
< 10f70d1 L
> 31e5b8e R
RUNNING: git -C clone log --format=ol --left-right @{u}...
10f70d1 L
31e5b8e R
-> NOT OK: no marks shown
RUNNING: git -C clone log --format=ol2 --left-right @{u}...
< 10f70d1 L
> 31e5b8e R
-> OK: marks shown
RUNNING: git -C clone log --graph --oneline --no-decorate --left-right @{u}...
< 10f70d1 L
> 31e5b8e R
RUNNING: git -C clone log --graph --format=ol --left-right @{u}...
< 10f70d1 L
> 31e5b8e R
-> OK: marks shown
RUNNING: git -C clone log --graph --format=ol2 --left-right @{u}...
< < 10f70d1 L
> > 31e5b8e R
-> NOT OK: marks shown twice
RUNNING: git -C clone log --oneline --no-decorate @{u}...
10f70d1 L
31e5b8e R
RUNNING: git -C clone log --format=ol @{u}...
10f70d1 L
31e5b8e R
-> OK: no marks shown
RUNNING: git -C clone log --format=ol2 @{u}...
< 10f70d1 L
> 31e5b8e R
-> NOT OK: marks shown
RUNNING: git -C clone log --graph --oneline --no-decorate @{u}...
* 10f70d1 L
* 31e5b8e R
RUNNING: git -C clone log --graph --format=ol @{u}...
* 10f70d1 L
* 31e5b8e R
-> OK: no marks shown
RUNNING: git -C clone log --graph --format=ol2 @{u}...
* < 10f70d1 L
* > 31e5b8e R

-> NOT OK: different marks shown twice ---

Am I missing something here ? Is this a known limitation ?
Thanks and cheers,
Philippe.
Message 1 of 1 in “Question about 'git log', custom formats, and '--left-right' and friends”
  1. Philippe BlainJan 20, 2021

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.