Finding the First Failing Commit with Bisect

A bisect narrows a known good-to-bad history using repeated classifications of intermediate commits.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Choose a property you can rerun
  2. Check the assumptions
  3. Use a reproducible observation to classify commits
  4. Confirm the candidate before drawing a conclusion

Choose a property you can rerun

If a known older report includes a final row and a newer one drops it, reuse the same fixture and check at sampled commits. Build a small reproducible input whose outcome separates the two states.

Check the assumptions

An unreliable test can misclassify a commit and point to the wrong region. A test that cannot build at one commit also needs a skip or another classification strategy. Monotone boundary searches explain the underlying division of the candidate range.[1]

Use a reproducible observation to classify commits

Suppose a serializer works at one known commit and emits a wrong row at a later one. A focused script can classify checked commits by comparing one fixed input with the expected output. Git bisect uses those observations to narrow the candidate history. See regression checks.

Known good: outputs two rows
Known bad: outputs one
At each candidate: build compatible setup and run the same check
Unclassifiable candidate: record separately under the tool's skip semantics

Confirm the candidate before drawing a conclusion

Flaky tests or changes in how a fixture runs can misclassify revisions. Check the candidate and pertinent parent again. A behavior that was introduced, fixed and reintroduced needs a carefully chosen interval.

References

  1. Scott Chacon and Ben Straub, Pro Git ↩