Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
843 views
in Technique[技术] by (71.8m points)

Making git diff --stat show full file path

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.  

That is the path starts with ... and only short path is shown.

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

By default git diff truncates its output to fit into a 80-column terminal.

You can override this by specifying values using the --stat option:

--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>.

For example, by setting the output value to a very large number:

git diff --stat=10000

Note that produces the path relative to the root of the git repository.

(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.)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...