让git diff --stat显示完整的文件路径 [英] Making git diff --stat show full file path

查看:461
本文介绍了让git diff --stat显示完整的文件路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在执行 git diff --stat 时,一些文件会以存储库基础的完整路径列出,但一些文件列出如下:

On doing git diff --stat some files are listed with full path from repository base but some files are listed as:

.../short/path/to/filename.  

这是以 ... 只显示短路径。

我希望 git diff 列出所有文件的完整文件路径它很容易被脚本处理。有什么方法可以获得 git diff 来始终显示完整路径

I would like git diff to list full file path for all files for it to be easily processed by a script. Is there some way I can get git diff to always show full path

推荐答案

< git diff 命令为 - stat 提供可选值:

The git diff command takes optional values for --stat:

--stat[=<width>[,<name-width>[,<count>]]]
       Generate a diffstat. You can override the default output width for
       80-column terminal by --stat=<width>. The width of the filename
       part can be controlled by giving another width to it separated by a
       comma. 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>.

(对于脚本,您可能需要使用 git diff-tree ,因为它更像是一个管道命令,尽管我怀疑你会没事的。注意你需要同样的额外文本和 - stat 在使用 git diff-tree 时使用 git diff 瓷器前端和 git diff-tree plumbing命令,是 git diff 查找您配置的选项,例如 diff.renames 来决定是否执行重命名检测。那么,加上前端 git diff 将会执行相当于 git diff-index ,例如,如果您将提交与索引进行比较,换句话说, git diff 读取你的配置自动调用正确的管道。)

(For scripting you might want to use git diff-tree directly since it's more of a "plumbing" command, although I suspect you'll be fine either way. Note that you need the same extra text with --stat when using git diff-tree. The essential difference between using the git diff "porcelain" front end, and the git diff-tree plumbing command, is that git diff looks up your configured settings for options like diff.renames to decide whether to do rename detection. Well, that, plus the front end git diff will do the equivalent of git diff-index if you're comparing a commit with the index, for instance. In other words, git diff reads your config and invokes the right plumbing automatically.)

这篇关于让git diff --stat显示完整的文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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