1

I am trying to track down a specific bug in my code, but the trouble is the bug appeared somewhere in a block of commits where the only way to check if the commit breaks is commented out, so I can't see which commit it is.

I need to change one line of code, and have that line merge into several commits, can this be done?

2 Answers 2

4

The best way to find the first (or last) commit with a certain behaviour in a block of commits is to use git bisect. More specifically: git bisect run.

To automate the entire process you need to write a script which comments out the one line in question and then starts a test. the script should exit with code 0 if the code is good and code 1 if the code is bad.

For an example read here: http://www.metaltoad.com/blog/mechanizing-git-bisect-bug-hunting-lazy.

Sign up to request clarification or add additional context in comments.

4 Comments

My issue is between the dependance of several files, but I am commenting out the printing of the result. The problem could be in one of around 10 files, but the result is echoed out in one place. Is bisect run that sophisticated? (I can't fathom it myself!!)
@MildFuzz: git bisect run is utterly primitive, it just runs your script and checks the exit code. Whatever you need to do to find out whether the code is good or not needs to be done in your script.
In this instance, without a result coming back it's hard to imagine where to look.
@Mild Fuzz, git bisect can also be run manually without a script. You do whatever you need to do to see if the problem is there or not, then run git bisect good or git bisect bad to go to the next step.
0

Perhaps you just need to use git bisect?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.