gitpowershellnewlinegit-bisect

Cannot replay git bisect: "error: couldn't get the oid of the rev"


I am attempting to replay a git bisect from an edited log to undo a mistake I made.

I mistakenly marked one of the commits as good when it should have been bad (or vice versa). I ran:

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

Then I edited that file to remove all the lines from the mistakenly labeled commit and below.

I then ran:

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

I'm now getting the error:

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?'

What is going on? How do I fix it? (Why is there a '?' at the end of the revision?)

I'm using git version 2.26.2.windows.1 on Windows 10. I use PowerShell 7 as my shell.


Solution

  • git bisect replay in Git before version 2.27 is unable to handle CRLF delimited files. The best fix for this is to upgrade to Git 2.27+, which has a contribution of mine to fix this.

    PowerShell's massaging of the output of git bisect log converted the originally LF-only output of git bisect log to CRLF. You can see where the errant CR is showing up: it's the '?' in the error message.

    If you cannot upgrade your copy of Git, there are a number of ways to avoid this:

    Hat tip to mklement0's answer for the PowerShell conversion one-liner. See it for nitty-gritty details.

    There's a proposal to add a -Delimiter argument to Set-Content. If that get implemented, such conversion will be simpler.