oh-my-git/levels/bisect/bisect

44 lines
1.3 KiB
Text
Raw Normal View History

2020-10-30 12:08:17 +01:00
title = Yellow brick road
cards = checkout commit-auto reset-hard bisect-start bisect-good bisect-bad
[description]
(Please zoom out a bit using your mouse wheel! :D)
Oh no! You have lost your key at some point during the day!
Sure, you could look at every single commit in an attempt to find it - but there's a better way: your time machine has a built-in way to find the point in time where things went wrong quickly!
First, play the "bisect start" card. Then, go to a commit where you don't have the key, and play the "bisect bad" card. Likewise, go to a commit early on where you have the key *in your pocket*, and play the "bisect good card".
2020-10-30 12:08:17 +01:00
After you've found the last good commit, reset the main branch to it. What happened to the key after you lost it?
[setup]
echo "You still have your key." > you
2021-02-11 11:32:55 +01:00
for i in {1..30}; do
if test $i -eq 12; then
2020-10-30 12:08:17 +01:00
echo "Your pocket is empty." > you
echo "Is on the ground." > key
fi
2021-02-11 11:32:55 +01:00
if test $i -eq 13; then
2020-10-30 12:08:17 +01:00
echo "Is holding a key in its beak." > bird
rm key
fi
2021-02-11 11:32:55 +01:00
if test $i -eq 14; then
2020-10-30 12:08:17 +01:00
rm bird
fi
git add .
git commit --allow-empty -m "$i"
done
[win]
# Find the last good commit
2021-02-11 11:32:55 +01:00
test "$(git log --pretty=%s main | head -1)" -eq 11
2020-10-30 12:08:17 +01:00
[congrats]
Well done! :) The only problem is that you now have to walk all the way back home, again...