I have an alias for git log
twoline.
[alias]
l = "log --graph --date=relative --decorate --abbrev-commit --pretty=format:'%h - %aD (%ar)%d%n %s - %an'"
It works nicely.
output#1:
$ git l -2
* 714a14e - Fri, 18 Nov 2016 00:04:19 -0800 (3 months ago) (HEAD -> dev, github/dev)
| Adding BitSet implementation. - hippy
* 87dce5f - Sat, 10 Dec 2016 12:50:40 -0800 (9 weeks ago)
| Turning on recommended code analysis rules. - hippy
However, with --name-status
, I can see a pipe after the author name.
output#2:
$ git l -2 --name-status
* 714a14e - Fri, 18 Nov 2016 00:04:19 -0800 (3 months ago) (HEAD -> dev, github/dev)
| Adding BitSet implementation. - hippy|
| M README.md
| A rm.Extensions/BitSet.cs
| M rm.Extensions/Properties/AssemblyInfo.cs
| M rm.Extensions/rm.Extensions.csproj
| A rm.ExtensionsTest/BitSetTest.cs
| M rm.ExtensionsTest/rm.ExtensionsTest.csproj
* 87dce5f - Sat, 10 Dec 2016 12:50:40 -0800 (9 weeks ago)
| Turning on recommended code analysis rules. - hippy|
| M rm.Extensions/GraphExtension.cs
| M rm.Extensions/Wrapped.cs
| M rm.Extensions/WrappedExtension.cs
| M rm.Extensions/rm.Extensions.csproj
If I were to add a %n
at the very end (so ...%an%n
), output#1 becomes 3 lines instead of 2.
I want --name-status
to look like this preferably but an extra newline before list of files is ok:
$ git l -2 --name-status
* 714a14e - Fri, 18 Nov 2016 00:04:19 -0800 (3 months ago) (HEAD -> dev, github/dev)
| Adding BitSet implementation. - hippy
| M README.md
| A rm.Extensions/BitSet.cs
| M rm.Extensions/Properties/AssemblyInfo.cs
| M rm.Extensions/rm.Extensions.csproj
| A rm.ExtensionsTest/BitSetTest.cs
| M rm.ExtensionsTest/rm.ExtensionsTest.csproj
|
* 87dce5f - Sat, 10 Dec 2016 12:50:40 -0800 (9 weeks ago)
| Turning on recommended code analysis rules. - hippy
| M rm.Extensions/GraphExtension.cs
| M rm.Extensions/Wrapped.cs
| M rm.Extensions/WrappedExtension.cs
| M rm.Extensions/rm.Extensions.csproj
This just seems like a bug to me as I cannot find anything in the pretty formats man page .
$ git version
git version 2.11.0.windows.1
How do I fix this the pretty format
?
Note: I have filed a bug here ( bug link ) and will update the ticket accordingly.
It is clearly a bug (the vertical bar is in the wrong place ; note the gap below the --name-status
items). Fortunately, there is a trivial workaround: use tformat
instead of plain format
. The difference is that tformat
adds a newline if needed, and not if not needed.
Note that --format
(available since Git version 1.6.3) is essentially a synonym for --pretty=tformat:
, since most user-facing code should usually be using tformat
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.