gpt4 book ai didi

git - 为什么 git blame --ignore-rev/--ignore-revs-file 对我不起作用?

转载 作者:行者123 更新时间:2023-12-03 13:40:10 30 4
gpt4 key购买 nike

git blame --ignore-revs-file显然是现代 Git 中存在的一个选项。
只有一个问题。它不起作用。
或者至少,它对我不起作用:
您可以将其添加到 shell 脚本中:

mkdir -p /tmp/blarp
cd /tmp/blarp
git init
cat << EOF > file.txt
one
two
three
EOF
git add file.txt
git commit --author "One <one@example.com>" -m 'one commit'
cat << EOF > file.txt
one
awesome
three
EOF
git add file.txt
git commit --author "Two <two@example.com>" -m 'two commits'
cat << EOF > file.txt
one
awesome
sauce
EOF
git add file.txt
git commit --author "One <one@example.com>" -m 'three commits'
git rev-parse HEAD~1 > ignore.txt
git blame --ignore-revs-file=ignore.txt file.txt
对我来说,这表明:
^b6d40d5 (One 2019-12-30 21:47:15 +0000 1) one
1c185c4c (Two 2019-12-30 21:47:15 +0000 2) awesome
d8b9bafd (One 2019-12-30 21:47:15 +0000 3) sauce
但我希望看到
^b6d40d5 (One 2019-12-30 21:47:15 +0000 1) one
^b6d40d5 (One 2019-12-30 21:47:15 +0000 2) two
d8b9bafd (One 2019-12-30 21:47:15 +0000 3) sauce
或者
^b6d40d5 (One 2019-12-30 21:47:15 +0000 1) one
d8b9bafd (One 2019-12-30 21:47:15 +0000 2) awesome
d8b9bafd (One 2019-12-30 21:47:15 +0000 3) sauce
但事实并非如此。我确实发现,如果更改只是空白更改,它们将被忽略……但 git 文档对此并不明确,只是建议:

--ignore-revs-file

Ignore revisions listed in file, which must be in the same format as an fsck.skipList. This option may be repeated, and these files will be processed after any files specified with the blame.ignoreRevsFile config option. An empty file name, "", will clear the list of revs from previously processed files.


任何线索为什么 git blame --ignore-revs-file=revs-to-ignore似乎不适合我?

最佳答案

检查 Git 2.29(2020 年第 4 季度)是否修复了以下问题:“ git blame --ignore-rev/--ignore-revs-file ”( man )未能验证其输入是否为有效修订版,并且未能考虑到用户可能想要提供带注释的标签而不是提交,已更正。
commit 610e2b9 , commit f58931c (2020 年 9 月 24 日)来自 Junio C Hamano ( gitster ) .
(由 Junio C Hamano -- gitster -- merge 于 commit 230ff3e ,2020 年 10 月 4 日)

blame: validate and peel the object names on the ignore list


The command reads list of object names to place on the ignore list either from the command line or from a file, but they are not checked with their object type (those read from the file are not even checked for object existence).

Extend the oidset_parse_file() API and allow it to take a callback that can be used to die (e.g. when an inappropriate input is read) or modify the object name read (e.g. when a tag pointing at a commit is read, and the caller wants a commit object name), and use it in the code that handles ignore list.



在 Git 2.30(2021 年第一季度)中,“ git blame --ignore-revs-file=<file> ( man)”学会了忽略输入中不存在的对象名称,而不是提示。
commit c714d05 (2020 年 11 月 10 日)来自 René Scharfe ( rscharfe ) .
(由 Junio C Hamano -- gitster -- merge 于 commit b4e245a ,2020 年 11 月 18 日)

blame: silently ignore invalid ignore file objects

Reported-by: Jean-Yves Avenard
Signed-off-by: René Scharfe
Reviewed-by: Barret Rhoden


Since 610e2b9240 ("blame: validate and peel the object names on the ignore list", 2020-09-24, Git v2.29.0-rc0 -- merge listed in batch #19) git blame(man) reports checks if objects specified with --ignore-rev and in files loaded with --ignore-revs-file and config option blame.ignoreRevsFile are actual objects and dies if they aren't. The intent is to report typos to the user.

This also breaks the ability to use a single ignore file for multiple repositories.
Typos are presumably less likely in files than on the command line, so alerting is less useful here.
Restore that feature by skipping non-commits without dying.

关于git - 为什么 git blame --ignore-rev/--ignore-revs-file 对我不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59537270/

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