* Question about 'git log', custom formats, and '--left-right' and friends
@ 2021-01-20 3:40 Philippe Blain
0 siblings, 0 replies; only message in thread
From: Philippe Blain @ 2021-01-20 3:40 UTC (permalink / raw)
To: Git mailing list
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.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-01-20 3:47 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-20 3:40 Question about 'git log', custom formats, and '--left-right' and friends Philippe Blain
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).