Stochastic bisection in Git
Stochastic bisection in Git
Posted Dec 14, 2021 20:50 UTC (Tue) by mathstuf (subscriber, #69389)In reply to: Stochastic bisection in Git by NYKevin
Parent article: Stochastic bisection in Git
Oh nifty. I knew of `log`, but had missed `replay`. However, I feel that `git bisect undo [n]` would also be useful (at least to avoid touching files all over the place in the process of restarting since I suspect that the replay is not done purely in-index quite yet[1]).
> You can build it yourself out of git bisect run, although built-in functionality would be Nice To Have. But if you've already turned the test into a single command, writing a wrapper script that applies/reverts a fixed patch is not *that* much extra work.
Sure, but that's generally a "hindsight is 20/20" situation. The problem is usually that such things are discovered in the process of bisecting, so by the time I have a robust reproducer script to give to `git bisect run`, I've already done a bisection…
[1] Willing to be pleasantly surprised though :) .
Posted Dec 14, 2021 21:24 UTC (Tue)
by NYKevin (subscriber, #129325)
[Link]
#!/bin/bash
patch -p2 /path/to/file.diff # Replace 2 with the correct number.
You would still need to handle the "what if patch(1) fails?" case, though.
Stochastic bisection in Git
git show -s --oneline
echo "Press ^D when finished testing this commit."
bash
echo -n "Was this commit (G)ood, (B)ad, or (S)kip? "
read REPLY
git reset --hard HEAD
case "$REPLY" in
g|good) exit 0;;
b|bad) exit 1;;
s|skip) exit 125;;
*) echo "Unrecognized input, aborting."; exit -1;;
esac