Home > Software design >  How to easily run git bisect with patches on top cleanly
How to easily run git bisect with patches on top cleanly

Time:11-20

I'm trying to run git bisect to find a broken commit, but the problem I have is that the brokenness isn't apparent without an extra series of patches applied on top. I'm just cherry-picking those out of another branch, but the problem I have is that at some steps in the bisect they don't apply cleanly and require some fixup. That shouldn't be a problem, but I can't seem to move on after doing the fixup.

So for example...

$ git bisect start
djrscally@valhalla:$ git bisect bad
djrscally@valhalla:$ git bisect good tags/v5.14-rc7
Bisecting: 13382 revisions left to test after this (roughly 14 steps)
[1ea3615b6168eaaf07445c8d32a4c6bc965d9579] iio: accel: sca3000: Use sign_extend32() instead of opencoding sign extension.
djrscally@valhalla:$ git cherry-pick --no-commit 820aca592e0c^..58915847b332
Auto-merging include/acpi/acpi_bus.h
Auto-merging drivers/acpi/scan.c
Auto-merging drivers/i2c/i2c-core-acpi.c
Auto-merging drivers/regulator/Makefile
CONFLICT (content): Merge conflict in drivers/regulator/Makefile
Auto-merging drivers/regulator/Kconfig
CONFLICT (content): Merge conflict in drivers/regulator/Kconfig
error: could not apply 6a7e459bf029... regulator: Introduce tps68470-regulator driver
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'

At this point I need to fix drivers/regulator/Makefile and Kconfig; at which point I expect to be able to carry on, but I can't:

djrscally@valhalla:$ git add .
djrscally@valhalla:$ git cherry-pick --continue
error: your local changes would be overwritten by cherry-pick.
hint: commit your changes or stash them to proceed.
fatal: cherry-pick failed

Aaaaaaaand I'm not really sure what to do at this point. git cherry-pick --skip seems to reset all the changes from the earlier cherry-picked commits. I can drop the --no-commit, but I'm not really sure how bisect will handle the fact that I suddenly dropped a ton of commits on top of the point it decided to bisect to.

How should I handle this?

CodePudding user response:

My first attempt would be, rather than cherry-pick iteratively, just do the whole batch at once:

git diff 820aca592e0c^..58915847b332 | git apply -3

then fix up the conflicts, it's the last step, add the resolutions and you're ready to test.

This might be a good spot for some manual rerere'ing, you do that by mkdir -p `git rev-parse --git-common-dir`/rr-cache once to tell git you're using rerere without the automation assists, then git rerere when you get the conflict notice, then fix anything that didn't already fix and git rerere again after you've added the resolutions.

  • Related