使用时git log --pretty=oneline --shortstat
,我得到了日志的紧凑表示形式:
% git log --pretty=oneline --shortstat
73c6eecd930c2f66d5c1e87fcca7ca9b0e356809 doing stuff with things
3 files changed, 134 insertions(+)
65b457d2e0e94e628e1b30204075540524c8a1d2 doing things with stuff
2 files changed, 4 insertions(+), 1 deletion(-)
...
375531279297af3c787855b0848b400f1c40b638 things with stuff doing
1 file changed, 2 insertions(+)
5501964b19815a07b64e1cd391e032147af33b8f with things doing stuff
25 files changed, 6746 insertions(+)
但是,如果我尝试使用的tformat
等价物oneline
,则会在统计信息之前得到一个额外的换行符:
% git log --pretty="%C(yellow)%H%Creset %s" --shortstat
73c6eecd930c2f66d5c1e87fcca7ca9b0e356809 doing stuff with things
3 files changed, 134 insertions(+)
65b457d2e0e94e628e1b30204075540524c8a1d2 doing things with stuff
2 files changed, 4 insertions(+), 1 deletion(-)
...
375531279297af3c787855b0848b400f1c40b638 things with stuff doing
1 file changed, 2 insertions(+)
5501964b19815a07b64e1cd391e032147af33b8f with things doing stuff
25 files changed, 6746 insertions(+)
没有--shortstat
标志(或--stat
)标志,这两个命令的输出是相同的,因此要加上这些标志。
我可以使用grep修复此问题:
[alias]
x-skip-empty-lines="!f(){ git $* --color=always | grep -vE '^(\\|{0,1}|\\e\\[[^m]*m)[[:space:]]*$' | less ;}; f"
logpatch= !git x-skip-empty-lines log --pretty='%C(yellow)%H%Creset %s' --shortstat
但是有没有办法避免首先产生换行符?
(git 1.8.3和2.0.1)
恐怕您对此无能为力。在log-tree.c中,git对于单行格式具有特殊情况,并且始终在shortstat
不使用if之前输出两个空行。
(我尝试不使用突出显示的行来编译git-log-原始--pretty=oneline
命令然后还会输出两个空行)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句