From Developer to InvestiGITor: Cracking the Case at AndroidMakers 2024

Kais Jaafoura
Bforbank Tech
Published in
4 min readApr 26, 2024
Captured by Soriya Thach

Walking inside the crowded hallways of AndroidMakers 2024, I was impressed by the excitement and passion. Everywhere I looked, people were engaged in conversation, ready to learn and give their expertise. But it was during a session with a title that immediately caught my eye — “Crime Scene InvestiGITor: There Has Been a Murder!” — that I experienced a true ‘aha moment…’

This wasn’t the usual dry developer chat. The speaker converted the room into a detective agency, and we, the audience, were all inexperienced investigators. What about the “murder”? A faulty build, a missing functionality, and a typical example of developer frustration. With a lighthearted reference to detective programs, the speaker led us through the dark alleyways of Git, the powerful version control system that coders utilize.

Version control software may sometimes feel like a mysterious black box, something we have to operate without fully knowing. However, this workshop tried to alter that. It promised to transform us from perplexed beginners into respected InvestiGITors capable of sniffing out and solving any version control problem with the precision of a seasoned sleuth.

The workshop covered the following real-world issues that developers face:

  • Did you accidentally commit a secret to the repository? Learn safe removal procedures, similar to those used for evidence disposal!
  • App unexpectedly broken, and you have no idea why? Become a code forensics specialist and track out the specific commit that created the problem.
  • Have you ever wished you could travel back in time to avoid a coding error? (Okay, sort of!) Git allows you to do just that, preventing code crimes before they occur.

Cracking the Case Using Git Bisect

Talking about the git bisect command

Git bisect is a tool that uses the dichotomous technique to pinpoint the guilty commit.

You have a suspect (the bug) and a list of possible culprits (your commits). Bisect works by systematically narrowing down the suspects until you find the commit that caused the bug.

This is how it works :

  1. Prepare the crime scene
  • First, use git checkout master to ensure you’re on the newest commit.
git checkout master
  • Then, find the two commits that you know for certain:

A “good” commit in which the bug is clearly not present (the alibi).

A “bad” commit that contains the bug (the crime scene).

  • To begin the investigation, run git bisect start , supplying the commit hashes for the good and bad commits.
git bisect start <good_commit_hash> <bad_commit_hash>Interrogation begins
  • Bisect will automatically checkout a commit from the middle of your history.
  • Now you must review the code and run your tests. Here is where you test the code to determine if the bug manifests.
  • If the tests fail and the bug exists (guilty), run git bisect bad.
git bisect bad
  • If the tests pass and the code remains functional (innocent), execute git bisect good.
git bisect good

3. Refine the Suspect Pool

  • Based on your response, git bisect removes half of the remaining commits as suspects.
  • It will then check out another commit for investigation, repeating step 2.

Unmasking the perpetrator

Once you’ve discovered the bug-causing commit, use git show to learn more about it.

git show <commit_hash>

<commit_hash> is the hash of the culprit commit

This command will display the commit message, author’s name and email address, as well as the date of creation.

This information can help you determine who made the change that caused the bug and what the intended goal was.

Remember that git bisect uses special markers to monitor both good and bad commits throughout the inquiry.

You can use git bisect reset to end the inquiry

git bisect reset

Finaly

This workshop was not only instructive, but also enjoyable. It promised to not only teach us the key Git abilities that every developer requires, but also to convert Git from a perplexing riddle into a powerful tool that we could fully grasp and use. So I put on my metaphorical detective hat, ready to bring the bugs to justice, solve the mystery of the wicked commit, and become a codebase hero!

To view the slides from this talk, follow the first link here: https://linktr.ee/bkadel

--

--