gpt4 book ai didi

linux - 如何使 diffstat 计数已删除和新添加的文件到 LOC 计数?

转载 作者:太空宇宙 更新时间:2023-11-04 03:34:30 26 4
gpt4 key购买 nike

diff -ur dir1 dir2 | diffstat

这与 git diff --stat 类似,但 diffstat 忽略“仅在 dir1”和“仅在 dir2”文件,而 git diff 将其分别添加到删除和插入计数中。有没有办法让 diffstat 做同样的事情?

最佳答案

更简单:

diff -urN dir1/ dir2/ |diffstat

使用 GNU diff 的 -N 选项,例如,当 comparing directories 时:

If only one file exists, diff normally does not show its contents; it merely reports that one file exists but the other does not. You can make diff act as though the missing file is empty, so that it outputs the entire contents of the file that actually exists. (It is output as either an insertion or a deletion, depending on whether the missing file is in the first or the second position.) To do this, use the --new-file (-N) option.

关于linux - 如何使 diffstat 计数已删除和新添加的文件到 LOC 计数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32076956/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com