git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Philippe Blain <levraiphilippeblain@gmail.com>
To: Git mailing list <git@vger.kernel.org>
Subject: Question about 'git log', custom formats, and '--left-right' and friends
Date: Tue, 19 Jan 2021 22:40:18 -0500	[thread overview]
Message-ID: <24504597-7c14-70aa-393b-2e18df2a51bb@gmail.com> (raw)

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.

                 reply	other threads:[~2021-01-20  3:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=24504597-7c14-70aa-393b-2e18df2a51bb@gmail.com \
    --to=levraiphilippeblain@gmail.com \
    --cc=git@vger.kernel.org \
    /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.
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).