In-class exercise for git bisect

Goal

The goal of this exercise is to improve git proficiency and to learn about systematic debugging, using git bisect.

Setup

  1. Make sure a Java 17+ JDK and Git are installed. The required software is already installed on attu.cs.washington.edu, if you prefer to do the exercise there.

  2. Not required, but strongly recommended: practice resolving a merge conflict.

Background (story time)

The developers of this application published the first release, which they tagged v1.0.0. Unfortunately, the developers introduced a defect at some point after the v1.0.0 release, which has existed in the code since. The automated testing infrastructure did not catch the defect. Since the developers were so excited about coding, they never manually checked a single test run.

The testing infrastructure executes “./gradlew clean build”. This command builds the application from scratch and runs all tests. If the command fails (i.e., returns a non-zero exit code), then the developers are notified.

Instructions

  1. Team up in groups of size 2, and self-assign to a group (in the In-class1-Git groupset) on Canvas. (If you are in a Canvas group of size 1, you can still submit.) In the past, groups found a pair-programming set up (in person or using screen-sharing for remote work) to be beneficial.

  2. Clone the following git repository and read its README.md file: https://github.com/mernst/basic-stats

  3. Checkout the most recent commit on the main branch (git checkout main) and run: “./gradlew clean build”. The software is defective, but the command ./gradlew clean build succeeds! Figure out why. Hint: run “`./gradlew clean build; echo $?” which prints the exit code of the gradle process.

  4. Check out the commit with tag v1.0.0 (git checkout v1.0.0), and compile and test the application again. All tests pass on this revision. If that is not the case, you have done something wrong.

  5. Determine the number of commits between tag v1.0.0 and HEAD (the latest revision on main). Include v1.0.0 and HEAD when counting, and note the command(s) that you used to automatically compute this number.

  6. Familiarize yourself with the git bisect command. Use git bisect to identify the commit that introduced the defect between version v1.0.0 and HEAD. (You might want to automate git bisect with a script.) Note the commit hash and log message of the defect-inducing commit. Verify that you correctly identified the defect-inducing commit.

Questions

  1. Why does the described automated testing infrastructure not catch the test failure? How could you improve it?

  2. How many commits exist between version v1.0.0 and HEAD (including v1.0.0 and HEAD)? List the command(s) that you used to automatically compute this number.

  3. Which commit (commit hash and message) introduced the defect? How did you verify that this commit indeed introduced the defect?

  4. How many commits, not including v1.0.0 and HEAD, did git bisect analyze before finding the first failing commit? List all commands you ran; this will likely be a series of calls to git bisect, or a call to your script. The staff must be able to run these commands, by copying (once) from your document and pasting into a command shell.

  5. What is the best-, worst-, and average-case run-time complexity of git bisect to discover the defect-inducing commit? Why?

  6. Which git command can you use to undo an undesirable commit? Does this command work in your case (for the commit you identified in question 3)? Briefly explain a problem that may occur when undoing a commit and what best practices mitigate this problem.

Deliverables

  1. A plain-text file with your answers to the questions above. Please list all group members.

Steps for turn-in

One team member should upload the deliverables to Canvas.