What I Discovered During My Search for the Right Beauty Box

Who here loves beauty? Who loves it, even more, when you get a steady flow of beauty products to enjoy on your self-care Sundays? If beauty products of all kinds give you a ton of excitement, you…

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:

Blockchain beyond crypto!!

Cryptocurrency has been making headlines right now and the foundation behind the crypto- blockchain, a new technology, has done much more than just revolutionizing digital money. There are n number…

What is hypersonic technology?

Much attention in the aerospace and aviation sectors has been devoted to hypersonics. Over the next few days at The Line, we will: · list hypersonic-related technology available for licensing through…

How to Get Your Teen to Agree with You

What does family time mean for you and your family? Which aspects come easy and naturally? Which aspects are challenges or struggles? Perhaps undesirable behaviors or unmet expectations come to mind…