0

I am lazy, and want to use git bisect to find a commit which introduced a failure with little work as possible.

I don't see a reason to supply a good-hash myself.

I think these input should be enough:

  • a script which return 0 on success, and other on failure
  • git is on a branch (not detached head). And test fails

The tool bisect (or a wrapper) could jump back in git history to find a good-hash itself.

Question: How to get this done?

guettli
  • 25,042
  • 81
  • 346
  • 663

2 Answers2

0

It's exactly what bisect does.

You can pass it a script to run and the script returns 0 or 1 for good or bad.

What else do you want bisect to do for you?


Simply read the doc:

Bisect run

If you have a script that can tell if the current source code is good or bad, you can bisect by issuing the command:

git bisect run my_script arguments

Note that the script (my_script in the above example) should exit with code 0 if the current source code is good/old, and exit with a code between 1 and 127 (inclusive), except 125, if the current source code is bad/new.

Any other exit code will abort the bisect process.

The special exit code 125 should be used when the current source code cannot be tested. If the script exits with this code, the current revision will be skipped (see git bisect skip above).

125 was chosen as the highest sensible value to use for this purpose, because 126 and 127 are used by POSIX shells to signal specific error status (127 is for command not found, 126 is for command found but not executable—​these details do not matter, as they are normal errors in the script, as far as bisect run is concerned).

Community
  • 1
  • 1
CodeWizard
  • 128,036
  • 21
  • 144
  • 167
  • If I use "git bisect run my_script arguments" I get this: `git bisect run py.test -k test_foobar You need to start by "git bisect start". You then need to give me at least one good and one bad revisions. (You can use "git bisect bad" and "git bisect good" for that.)` – guettli Mar 02 '16 at 10:49
  • You need to specify the start and end point of course. One you set them up execute the script. – CodeWizard Mar 02 '16 at 11:31
  • your answer does not match the question. Please tell me what is not clear in my question. Maybe the wording is not good? Tell me if the question can be more explicit. – guettli Mar 02 '16 at 12:28
  • Git cant find for you the "first" hash, you have to supply it. It can be the first commit your repo but again git cant guess it and you the minimum data is the good/bad pair commits. – CodeWizard Mar 02 '16 at 12:54
  • are you sure this is not possible? I am not math expert, and I have not understood what turing complete really means, but I guess it is possible. – guettli Mar 02 '16 at 13:16
0

jump back in git history to find a good-hash itself

That sounds simple to do: run your script for master~1, then master~2, master~4 ... etc until it returns 0 or bring you to original commit (it should fail to find the commit, then by bisection you will find the greatest N so that master~N is still valid).

But I'm not sure you will be happy with that:

  1. You can eventually step into previous break of the test. Then subsequent bisection may give you incorrect result. If you don't make any assumption about history, then any sequence except checking each commit has this risk.
  2. How are you sure that the script is correct, if you have not run it with any good revision?
max630
  • 8,762
  • 3
  • 30
  • 55