简体   繁体   English

Git log相当格式,占位符后的换行符非空

[英]Git log pretty format, newline after placeholder if non-empty

I've got a git alias for a log using the pretty format: 我使用漂亮的格式有一个日志的git别名:

lg = log -10 --graph --abbrev-commit --pretty=format:'%C(auto)%d%Creset%n %C(bold yellow)%h%Creset - %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'

Which gives the following: 这给出了以下内容:

在此输入图像描述

I can't seem to find a way to make a new line after the reference names only if the placeholder is non-empty. 只有在占位符非空时,我似乎无法找到在引用名称后面创建新行的方法。

The pretty formats wiki page has operators to add or remove (+ or -) the newline coming before the placeholder but not after. 漂亮的格式wiki页面有运算符来添加或删除(+或 - )在占位符之前但不在之后的换行符。

This is not supported natively by Git: you would have to process/parse the output to get the right result) Git本身不支持这种情况:您必须处理/解析输出才能获得正确的结果)

But this could also be the opportunity for a simple patch, much like the one which originally introduced the Pretty-format: %[+-]x mechanism: commit 9fa708d, git 1.6.6-rc1, Oct. 2009 . 但这也可能是一个简单补丁的机会,就像最初引入漂亮格式的那个: %[+-]x机制: 提交9fa708d,git 1.6.6-rc1,2009年10月

Maybe %[*/]x , for adding line-feed after the expansion of %x . 也许%[*/]x ,用于 %x扩展添加换行符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM