Git 2.22(2019 年第 2 季度)会让这一点变得更加清晰。
"git log -L<from>,<to>:<path>
" with "-s
" 没有压制补丁
输出应有的样子。
此问题已得到纠正。
See commit 05314ef (11 Mar 2019), and commit 9f607cd (07 Mar 2019) by Jeff King (peff).
(Merged by Junio C Hamano -- gitster -- in commit 31df2c1, 09 Apr 2019)
line-log
:检测不支持的格式
如果您使用“log -L
“ 输出格式如 “--raw
" or "--stat
”,我们将默默地忽略格式并只输出正常的补丁。
让我们检测并抱怨这一点,这至少告诉用户发生了什么。
现在它会清楚地显示:
-L does not yet support diff formats besides -p and -s
在 Git 2.25(2020 年第一季度)中,文档添加了更多内容。
See commit 2be4586, commit 2be4586 (26 Dec 2019) by Philippe Blain (phil-blain).
(Merged by Junio C Hamano -- gitster -- in commit c4117fc, 06 Jan 2020)
doc: log
, gitk
:记录接受的行日志差异格式
目前行日志功能(git log -L
)仅支持
显示补丁输出(-p | --patch
,其默认行为)并抑制它
(-s | --no-patch
).
在代码中添加了一个检查以达到此效果05314ef
(line-log
:检测不支持的格式,2019-03-10)但文档未更新。
明确提及:
- that
-L
暗示-p
,
可以使用抑制补丁输出-s
,
- 并且不允许所有其他差异格式。
And:
行号、正则表达式或偏移参数以及git log -L <start>,<end>:<file>
,或函数名正则表达式git log -L :<funcname>:<file>
必须存在于起始版本中,否则命令将退出并出现致命错误。
所以,除了You can specify this option more than once
, 你有:
Implies --patch
.
可以使用以下命令抑制补丁输出--no-patch
,但其他差异格式(即--raw
, --numstat
, --shortstat
, --dirstat
, --summary
, --name-only
, --name-status
, --check
)目前尚未实施。
With Git 2.30 (Q1 2021), "git log(man)" is documented to take no pathspec, but this was not enforced by the command line option parser, which has been corrected.
See commit 39664cb (04 Nov 2020) by Junio C Hamano (gitster).
(Merged by Junio C Hamano -- gitster -- in commit f8a1cee, 18 Nov 2020)
log: 诊断-L
与 pathspec 一起使用作为错误
Heled-by: Jeff King
The -L
选项被记录为不接受任何路径规范,但命令行选项解析器已允许组合而无需检查到目前为止。
确保当-L
选项已生效以解决此问题。
顺便说一句,此更改修复了命令行选项解析器中的另一个错误,该错误允许-L
选项与一起使用--follow
option.
因为后者只需要给定一个路径,但前者不需要路径规范,因此它们会自动变得相互不兼容。
因为-L
选项自行重命名,没有理由给出--follow
同时。
新的测试称它们可能会失败,并出现“-L
and --follow
不兼容”而不是“-L
和路径规范不兼容”。
目前,预期的失败只能来自后者,但这是为了面向未来,以防万一我们决定添加代码来明确地死掉-L
and --follow
一起使用。