我注意到如果你这样做
$ git diff -M --stat
out_of_the_water/out_of_itself => he_watches_my_gauze_dress/blowing_on_the_line | 0
1 file changed, 0 insertions(+), 0 deletions(-)
或
$ git diff -M --stat | cat
.../out_of_itself => he_watches_my_gauze_dress/blowing_on_the_line | 0
1 file changed, 0 insertions(+), 0 deletions(-)
输出不同,第一个文件名被截断。这对我来说是一个问题,因为我想隔离两个文件名:
$ git diff -M head~1 --stat | perl -ne 'print "$1 $2" if m/^\s*(.*?) => (.*?) \|/'
如果通过管道传输到另一个进程,如何配置 git 提供相同的输出?
最佳答案
我很想说 RTFM,但为了您的利益,我将在此处引用相关部分:
--stat[=<width>[,<name-width>[,<count>]]]
Generate a diffstat. By default, as much space as necessary will be used for the filename part, and the rest for the graph part. Maximum width defaults to terminal width, or 80 columns if not connected to a terminal, and can be overridden by
<width>
. The width of the filename part can be limited by giving another width<name-width>
after a comma. The width of the graph part can be limited by using--stat-graph-width=<width>
(affects all commands generating a stat graph) or by settingdiff.statGraphWidth=<width>
(does not affectgit format-patch
). By giving a third parameter<count>
, you can limit the output to the first<count>
lines, followed by...
if there are more.These parameters can also be set individually with
--stat-width=<width>
,--stat-name-width=<name-width>
and--stat-count=<count>
.
所以如果没有管道,宽度就是你的终端宽度,比80个字符宽;对于管道,没有终端宽度,因此宽度为 80。因此只需使用 --stat=99999
并且任何内容都不应该被缩写。
关于git - 如何在管道传输时配置 git 输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41280494/