Git日志漂亮格式,占位符后的换行符(如果非空) [英] Git log pretty format, newline after placeholder if non-empty

查看:364
本文介绍了Git日志漂亮格式,占位符后的换行符(如果非空)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用漂亮格式的日志的git别名:

I've got a git alias for a log using the pretty format:

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'

其中提供以下内容:

仅当占位符为非空时,我似乎无法找到一种在引用名称后添加新行的方法.

I can't seem to find a way to make a new line after the reference names only if the placeholder is non-empty.

漂亮格式Wiki页面具有要添加或删除的操作符(+或-)换行符位于占位符之前,而不是之后.

The pretty formats wiki page has operators to add or remove (+ or -) the newline coming before the placeholder but not after.

推荐答案

Git本身不支持此功能:您必须处理/解析输出以获得正确的结果)

This is not supported natively by Git: you would have to process/parse the output to get the right result)

但这也可能是一个简单补丁的机会,就像最初引入了Pretty-format的那个补丁一样:%[+-]x机制:

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,用于在%x的扩展名之后添加换行符.

Maybe %[*/]x, for adding line-feed after the expansion of %x.

这篇关于Git日志漂亮格式,占位符后的换行符(如果非空)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆