Belief

What is a belief? One thing to say is what one believes in. But what makes you believe what you believe in? The fact that a particular idea or assumption is Subscribed to by your brain much that it…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Git Bisect

Often times in project, something that was working fine breaks later. Mostly it is because of some commit that was made after when the project was working good.

Suppose for an android app, I got the task to make some design changes to a simple screen. After the task is done and few commits later, it looked like:

Here everything was fine except for the position of the round button which has moved to left-top of the screen.

Git log looks like this:

It was all good before I started to make change, i.e till commit A3-86c07ee but during the test at commit A8- c20a76e I realized it is broken. In between the commits [A3...A8]break may have been introduced, after which all its following commits will have this issue. Lets call all the ones where the bug exists bad and others good.

Next thing anyone does, is to find the commit that caused the bug, i.e first bad commit. Generally what one does is, go back to every commit until working version is found i.e last good commit, or go to last known commit where project was working fine and checkout forward to find the broken version i.e first bad commit.

If the project is small, with one or couple of people working on it and there are few commits in between that route can work. But for large codebase or where the commits are frequent it can be not so fun task.

It is simple with following steps:

Git checks out to some commit in between with message:

Simple rule after the git bisect starts to search commits; Test the version and,

i.e, In our case Git checked out at commit 48ff1b19942da6e3e160c1a46de9cb5eb0183c8d which is A5-f8ff1b1 where I have changed the color of the round button from red to blue. When I built on this version and made a test on my phone issue was still there.

So I continued with command git bisect bad and the result message was:

Git checked out at A4- d95fc76 , after the test there was no issue on this version, so I continued with command git bisect good and got the message

Finally, the culprit commit is found which turned out to be A5- 48ff1b1

Checking out to this commit,

git checkout 48ff1b1 and executing diff with A4, i.e

git diff d95fc76,

There was the change in line which affected the position of the button.

Now after the issue is identified move forward with git bisect reset which resets the bisect mode and checks out to head where git bisect was started.

Now, fix it and enjoy.

You can for sure manually do these checkouts to previous version and test until the first bad commit is identified. Bisect simply helps by doing binary search on commits and makes the process much easier specially with large number of commits.

You can automate the process using script, that runs test on each commit and can return non zero value when it fails.

Add a comment

Related posts:

STYX Project Donation Phase

The STYX Project will not conduct a public ICO. Instead all funds will come exclusively from community contributions in order to increase development and marketing efforts. STYX is attempting to…

Orange Chicken Pizza

I made a lot of orange chicken one night, so what to do with all the leftovers? Make an orange chicken pizza! Ingredients: 1 lb chicken thighs, cut in bite size pieces 1 cup, plus 2 T cornstarch…

Low Season Bullies

Night after night when all is tight there’s no tourist money around; local lads squabble local lads brawl, then go bash down a foreigners door. Swing a baseball bat give them a laugh down the end…