无法重放git bisect:"error: couldn't get the oid of the rev"。

问题描述 投票:0回答:1

我正试图重播一个 git bisect 从编辑的日志到 拨乱反正 是我做的。

我错误地将其中一个提交标记为好,而它应该是坏的(或反之)。我运行了这个文件。

git bisect log > C:\temp\bisect.log
# Alternatively
git bisect log | Set-Content -Encoding ASCII C:\temp\bisect.log

然后我编辑了那个文件,删除了错误标记的提交和下面的所有行。

然后我又运行了。

git bisect reset
git bisect replay c:\temp\bisect.log

现在出现了错误

We are not bisecting.
Bisecting: 5211 revisions left to test after this (roughly 12 steps)
[9bc79b2f25a3724376d7af19617c33749a30ea3a] Merge branch 'release/2.1' into release/2.2
error: couldn't get the oid of the rev '9bc79b2f25a3724376d7af19617c33749a30ea3a?'

这是怎么回事?我该如何解决?(为什么修订版的末尾有一个'?'?)。

我在Windows 10上使用git 2.26.2.2.windows.1版本。我使用 PowerShell 7 作为我的 shell。

git powershell newline git-bisect
1个回答
1
投票

Christopher Warrington 的 (chwarr,OP)补丁已经合并在Git 2.27(2020年第二季度)。"git bisect replay"在使用CRLF行结束时,输入文件有问题,已被纠正。

参见 提交6c722cb (2020年5月7日)由 Christopher Warrington (chwarr). (合并者为: Junio C Hamano -- -- gitster --承诺f9dbe28(2020年5月14日)

bisect:允许在 "git bisect replay "输入中使用CRLF行尾。

签收人:克里斯托弗-沃灵顿

我们宣传说,在送入" "之前,可以在您的编辑器中修正二分法日志。git bisect replay",但有些编辑器可能会将行尾变成CRLF。

更新输入行的解析器,使行末的CR被忽略。

如果有人故意使用带有内嵌 CRs 的 termsrevs,那么通过这一改动,重放这样的二分法将不再有效。我怀疑这种情况非常罕见。


1
投票

git bisect replay 2.27 版之前的 Git 无法处理以 CRLF 分隔的文件。最好的解决方法是升级到 Git 2.27+,它有以下功能 献计献策.

PowerShell对输出的按摩。git bisect log 将原本只有LF输出的 git bisect log 到CRLF。你可以看到错误的CR显示在哪里:就是错误信息中的'?'。

如果您无法升级 Git 副本,有很多方法可以避免这种情况。

  • 将文件从CRLF转换回LF。
    • 如果你使用的是PowerShell 5+。((Get-Content C:\temp\bisect.log ) -join "`n") + "`n" | Set-Content -NoNewline \temp\bisect-lf.log
  • 让你的文本编辑器在编辑时用LF保存文件。
  • 使用CMD而不是PowerShell。然后.., git bisect log > c:\temp\bisect.log 不会改变新行。

帽子提示 mklement0's 回答 为PowerShell转换单行本。琐碎的细节请看它。

有一个 建议 添加 -Delimiter 争论 Set-Content. 如果实现了,这样的转换将更加简单。

© www.soinside.com 2019 - 2024. All rights reserved.