git日志中使用tformat的额外换行符

git日志中使用tformat的额外换行符,git,git-log,Git,Git Log,当我使用git log--pretty=oneline--shortstat时,我得到了我的日志的紧凑表示: % git log --pretty=oneline --shortstat 73c6eecd930c2f66d5c1e87fcca7ca9b0e356809 doing stuff with things 3 files changed, 134 insertions(+) 65b457d2e0e94e628e1b30204075540524c8a1d2 doing things w

当我使用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(+)
但是,如果我尝试使用
t格式
相当于
oneline
,我会在stat之前得到一个额外的换行符:

% 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)

恐怕您对此无能为力。在中,git对单行格式有一个特殊情况,如果未使用,则总是在
shortstat
之前输出两个空行


(我试图在没有突出显示的行的情况下编译git日志-原始的
--pretty=oneline
命令还输出两个空行)

pretty的格式等价物是什么意思?你是说相当于pretty=oneline的格式吗(我不想太挑剔,我只是不确定,似乎这个问题需要正确阅读才能回答。而且我不是git超级英雄)。。。回到主题,这似乎与
pretty=oneline
不同。(由于输出不同)格式表达式来自何处?hek2mgl:它与这组标志等效(我在我的
~/.gitconfig
中设置
color=auto
)。对于
--abbrev commit
--decoration
,您需要一些不同的东西,但我想给出一个小案例。