Re: [BUG] git log --graph --pretty=format misplaces graph characters when -p given
- From
D. Ben Knoble <ben.knoble@gmail.com>
- Date
- Feb 2, 2026, 20:27 UTC
- Message-ID
- <CALnO6CCqwnTcQWSUBPV+o3OO=sMZJjj6jRuMNnBjV3F-dYx+0w@mail.gmail.com>
- In-Reply-To
- <trinity-ed0884d3-098e-44be-aa1a-a96f664ce7ca-1770049279182@trinity-msg-rest-gmx-gmx-live-5dd78c558c-fv4g4>
On Mon, Feb 2, 2026 at 11:22 AM <lolligerhans@gmx.de> wrote:
Show 53 quoted lines
>
> Hello,
>
> Git can pretty-print a commit graph with git log --graph and a custom --pretty
> format. I alias some uses of git log --graph --pretty, to which I then want to
> manually add "-p" upon invocation.
>
> When using the working command
> git log --graph --pretty='format:%h'
> and appending "-p/--patch", the output appears erroneous:
> git log --graph --pretty='format:%h' -p (1)
>
> Expected output:
> 1 ! * d0c34d4
> 2 | diff --git a/git-bugreport-2026-02-02-1427.txt b/git-bugreport-2026-02-02-1427.txt
> 3 | index 5a83af1..2740fd4 100644
> 4 | --- a/git-bugreport-2026-02-02-1427.txt
> 5 | +++ b/git-bugreport-2026-02-02-1427.txt
> 6 | @@ -1,22 +1,53 @@
> 7 | Some context-before line
> 8 | -Some removed line
> --- | ...
> 101 | +Some added line
> 102 | Some context-after line
> 103 ! |
> 104 ! * 28299b2
> 105 | diff --git a/git-bugreport-2026-02-02-1427.txt b/git-bugreport-2026-02-02-1427.txt
> 106 | new file mode 100644
> 107 | index 0000000..5a83af1
> --- | ...
>
> Actual output, shortened, with line numbers:
> 1 ! * d0c34d4|
> 2 | diff --git a/git-bugreport-2026-02-02-1427.txt b/git-bugreport-2026-02-02-1427.txt
> 3 | index 5a83af1..2740fd4 100644
> 4 | --- a/git-bugreport-2026-02-02-1427.txt
> 5 | +++ b/git-bugreport-2026-02-02-1427.txt
> 6 | @@ -1,22 +1,53 @@
> 7 | Some context-before line
> 8 | -Some removed line
> --- | ...
> 101 | +Some added line
> 102 | Some context-after line
> 103 !
> 104 ! * 28299b2|
> 105 | diff --git a/git-bugreport-2026-02-02-1427.txt b/git-bugreport-2026-02-02-1427.txt
> 106 | new file mode 100644
> 107 | index 0000000..5a83af1
> --- | ...
>
> In the actual output, note the trailing "| " sequences in lines {1, 104} and the
> missing graph character in line 103. I believe the sequence in line 1 belongs to
> line 103.Yep. I think this is because format:%h doesn't add a newline by default. With tformat:%h or format:%h%n, the issue goes away. (See "git help log" under "tformat:"—this is probably what you want in order to get "oneline"-style format.)
-- D. Ben Knoble