我正在开发一个R包,它应该在粒度级别上解析git存储库历史。在用来自GitHub的开源项目验证某些解析结果时,我遇到了一些意想不到的事情。在以前的包验证工作中,我通过git日志的输出成功地重构了几个git存储库中每个文件的行数,因此我认为使用git log获取更改文件的全面信息是一个有效的途径。但是,我在前面提到的项目中找到了一个提交,其中git日志似乎没有传递关于已更改的文件的所有信息:带有哈希184f6c71dee03c66c7adaacb024b70d99075ea75的提交。当将头重置到此提交并同时运行git log --stat和git show --log时,我得到以下内容:
$ git log --stat
commit 184f6c71dee03c66c7adaacb024b70d99075ea75
Merge: 32e47a3 d203300
Author: ***
Date: Wed Nov 12 10:39:51 2014 +0100
merge changes from master branch
commit d203300bbe45981dab15b49c3c08deb31ad46466
Merge: 4b63f4e c8ae895
Author: ***
Date: Wed Nov 12 10:35:36 2014 +0100
[ output truncated ]
commit 32e47a32f3cc60b5705e9df93cdc6b730fae380b
Author: ***
Date: Tue Nov 11 18:00:55 2014 +0100
Added the internal class template `MatrixColumnVisitor` to represent
`VectorVisitor` concept for a column that is a `matrix`. Part of #602
NEWS.md | 3 +++
inst/include/dplyr.h | 1 +
inst/include/dplyr/MatrixColumnVisitor.h | 167 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
inst/include/dplyr/VectorVisitorImpl.h | 4 +++-
inst/include/dplyr/visitor.h | 17 ++++++++++++++---
inst/include/dplyr/white_list.h | 4 ++++
tests/testthat/test-filter.r | 12 ++++++++++++
7 files changed, 204 insertions(+), 4 deletions(-)
[ output truncated ]和
$ git show --stat
commit 184f6c71dee03c66c7adaacb024b70d99075ea75
Merge: 32e47a3 d203300
Author: ***
Date: Wed Nov 12 10:39:51 2014 +0100
merge changes from master branch
NEWS.md | 4 ++--
R/RcppExports.R | 4 ++++
R/src-sql.r | 2 +-
inst/include/dplyr/NamedListAccumulator.h | 12 ++++++------
inst/include/dplyr/Result/LazyGroupedSubsets.h | 4 ++--
inst/include/dplyr/Result/LazySubsets.h | 4 ++--
inst/include/dplyr/Result/Name.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++
inst/include/dplyr/Result/all.h | 1 +
src/RcppExports.cpp | 15 +++++++++++++++
src/dplyr.cpp | 29 ++++++++---------------------
src/strings_addresses.cpp | 19 +++++++++++++++++++
tests/testthat/test-joins.r | 7 +++++++
tests/testthat/test-mutate.r | 18 ++++++++++++++++++
13 files changed, 131 insertions(+), 34 deletions(-)这很令人惊讶因为我以为
git log --stat和
git show --stat给我同样的信息。情况并非如此,因为从git log输出中,我得出的结论是,在提交感兴趣的文件时没有发生任何更改。
当查看提交论GitHub或RStudio git选项卡时,我可以看到此提交不是空的,即用git show显示的信息似乎是正确的,在我看来,该提交的git log缺少信息。
知道为什么会有这种差异吗?正如所指出的,对于大量提交,我可以从git log正确地再现git存储库中每个文件的行数,但对于这个库则不能。我正在macOS上运行git 2.9.2。提前谢谢。
发布于 2018-01-27 23:02:25
默认情况下,git log跳过显示合并提交的差异,而git show显示合并提交的组合差异。将--cc (显示组合差异)添加到git log选项中,告诉git log显示合并的组合差异(或它们的统计数据)。
注意,组合差异的用处有限。为了进行正确的分析,您可能需要-m,这是git log和git show都接受的一个选项。它告诉命令,实际上,将每个合并拆分为多个虚拟提交。合并提交具有n个父级,其中n个-m使Git将提交A与父P1、P2、.、Pn转换为带有父P1的提交A-P1;提交A-P2与父P2;.;提交A与父Pn,然后显示(或--stat)每个提交。
https://stackoverflow.com/questions/48481395
复制相似问题