git日志中缺少换行符--图形--格式=。。。是否使用文件状态切换?

git日志中缺少换行符--图形--格式=。。。是否使用文件状态切换?,git,git-log,Git,Git Log,我正在尝试获取带有文件状态信息的自定义格式git日志。然而,我在新线定位上遇到了一个奇怪的小问题 显然,每当使用--format或--pretty参数时,通常会忽略文件状态信息后插入的换行符。这会导致一些难以读取的输出,如 >> git log -3 --graph --name-status --format=%h:%s * eee8e08:Second commit With more details in the body. | | M hello.txt * b6146f7:

我正在尝试获取带有文件状态信息的自定义格式git日志。然而,我在新线定位上遇到了一个奇怪的小问题

显然,每当使用
--format
--pretty
参数时,通常会忽略文件状态信息后插入的换行符。这会导致一些难以读取的输出,如

>> git log -3 --graph --name-status --format=%h:%s
* eee8e08:Second commit With more details in the body.
|
| M hello.txt
* b6146f7:First commit.
|
| A hello.txt
| A world.txt
* 30cb21f:We start from here. Bla bla bla.
其中,文件状态看起来与错误的提交组合在一起

如果不需要
--graph
选项,可以通过在格式的开头添加换行符(
%n
)来轻松修复它,但是使用--graph这只会导致更奇怪的外观,将提交消息从表示图中注释的
*
移开

>> git log -3 --graph --name-status --format=%n%h:%s
*
| 1868195:Second commit With more details in the body.
|
| M hello.txt
*
| 0f03672:First commit.
|
| A hello.txt
| A world.txt
*
| 033f27f:We start from here. Bla bla bla.
缺少换行符会影响所有文件状态切换(例如,
--name status
--stat
--numstat

作为参考,在没有格式化命令的情况下,详细消息具有更好的换行位置

>> git log -3 --graph --name-status
* commit eee8e08d3c892e96228844bcdc6324dc895041af
| Author: me <me@me.org>
| Date:   Wed Nov 22 16:26:58 2017 +0100
|
|     Second commit
|     With more details in the body.
|
| M hello.txt
|
* commit b6146f70b3406508f5b1300c8cda6fd954d3eadd
| Author: me <me@me.org>
| Date:   Wed Nov 22 16:26:58 2017 +0100
|
|     First commit.
|
| A hello.txt
| A world.txt
|
* commit 30cb21f8aba82b30a2f780165533b477cb4555f9
| Author: me <me@me.org>
| Date:   Wed Nov 22 16:26:58 2017 +0100
|
|     We start from here.
|     Bla bla bla.
git日志-3——图形——名称状态 *提交eee8e08d3c892e96228844bcdc6324dc895041af |作者:我 |日期:2017年11月22日星期三16:26:58+0100 | |第二次提交 |身体里有更多的细节。 | |M hello.txt | *提交b6146f70b3406508f5b1300c8cda6fd954d3eadd |作者:我 |日期:2017年11月22日星期三16:26:58+0100 | |先承诺。 | |A hello.txt |A world.txt | *提交30CB21F8ABA82B30A2F78016553B477CB4555F9 |作者:我 |日期:2017年11月22日星期三16:26:58+0100 | |我们从这里开始。 |呜呜呜呜。 这使得消息、头和文件状态的分组更加清晰

是否有某种方法可以将文件状态信息转换为自定义日志格式,而不丢失将其与上一次提交分隔开的换行符



作为参考,输出是使用脚本在测试存储库中创建的。

这应该可以完成以下工作:
git log-3--graph--name status--pretty='format:%h:%s%n'

默认情况下,在格式化中,git使用的是
t格式。看见通过将其设置为
格式
,新行将正常添加

我认为它会因此而更改为tformat(来自git doc):


这应该可以完成以下任务:
git log-3——图形——名称状态——pretty='format:%h:%s%n'

默认情况下,在格式化中,git使用的是
t格式。看见通过将其设置为
格式
,新行将正常添加

我认为它会因此而更改为tformat(来自git doc):

In addition, any unrecognized string that has a % in it is interpreted
as if it has tformat: in front of it. For example, these two are
equivalent:
$ git log -2 --pretty=tformat:%h 4da45bef
$ git log -2 --pretty=%h 4da45bef