@@ -3,7 +3,7 @@ git-bisect(1)
3
3
4
4
NAME
5
5
----
6
- git-bisect - Find the change that introduced a bug by binary search
6
+ git-bisect - Find by binary search the change that introduced a bug
7
7
8
8
9
9
SYNOPSIS
@@ -39,7 +39,8 @@ help" or "git bisect -h" to get a long usage description.
39
39
Basic bisect commands: start, bad, good
40
40
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
41
41
42
- The way you use it is:
42
+ Using the Linux kernel tree as an example, basic use of the bisect
43
+ command is as follows:
43
44
44
45
------------------------------------------------
45
46
$ git bisect start
@@ -48,61 +49,63 @@ $ git bisect good v2.6.13-rc2 # v2.6.13-rc2 was the last version
48
49
# tested that was good
49
50
------------------------------------------------
50
51
51
- When you give at least one bad and one good versions, it will bisect
52
- the revision tree and say something like:
52
+ When you have specified at least one bad and one good version, the
53
+ command bisects the revision tree and outputs something similar to
54
+ the following:
53
55
54
56
------------------------------------------------
55
57
Bisecting: 675 revisions left to test after this
56
58
------------------------------------------------
57
59
58
- and check out the state in the middle. Now, compile that kernel, and
59
- boot it. Now, let's say that this booted kernel works fine, then just
60
- do
60
+ The state in the middle of the set of revisions is then checked out.
61
+ You would now compile that kernel and boot it. If the booted kernel
62
+ works correctly, you would then issue the following command:
61
63
62
64
------------------------------------------------
63
65
$ git bisect good # this one is good
64
66
------------------------------------------------
65
67
66
- which will now say
68
+ The output of this command would be something similar to the following:
67
69
68
70
------------------------------------------------
69
71
Bisecting: 337 revisions left to test after this
70
72
------------------------------------------------
71
73
72
- and you continue along , compiling that one , testing it, and depending
73
- on whether it is good or bad, you say "git bisect good" or "git bisect
74
- bad", and ask for the next bisection.
74
+ You keep repeating this process , compiling the tree , testing it, and
75
+ depending on whether it is good or bad issuing the command "git bisect good"
76
+ or "git bisect bad" to ask for the next bisection.
75
77
76
- Until you have no more left, and you'll have been left with the first
77
- bad kernel rev in "refs/bisect/bad".
78
+ Eventually there will be no more revisions left to bisect , and you
79
+ will have been left with the first bad kernel revision in "refs/bisect/bad".
78
80
79
81
Bisect reset
80
82
~~~~~~~~~~~~
81
83
82
- Oh, and then after you want to reset to the original head, do a
84
+ To return to the original head after a bisect session, you issue the
85
+ following command:
83
86
84
87
------------------------------------------------
85
88
$ git bisect reset
86
89
------------------------------------------------
87
90
88
- to get back to the original branch, instead of being on the bisection
89
- commit ("git bisect start" will do that for you too, actually: it will
90
- reset the bisection state).
91
+ This resets the tree to the original branch instead of being on the
92
+ bisection commit ("git bisect start" will also do that, as it resets
93
+ the bisection state).
91
94
92
95
Bisect visualize
93
96
~~~~~~~~~~~~~~~~
94
97
95
- During the bisection process, you can say
98
+ To see the currently remaining suspects in 'gitk', the following command
99
+ is issued during the bisection process:
96
100
97
101
------------
98
102
$ git bisect visualize
99
103
------------
100
104
101
- to see the currently remaining suspects in 'gitk'. `visualize` is a bit
102
- too long to type and `view` is provided as a synonym.
105
+ `view` may also be used as a synonym for `visualize`.
103
106
104
- If 'DISPLAY' environment variable is not set, 'git log' is used
105
- instead. You can even give command line options such as `-p` and
107
+ If the 'DISPLAY' environment variable is not set, 'git log' is used
108
+ instead. You can also give command line options such as `-p` and
106
109
`--stat`.
107
110
108
111
------------
@@ -112,57 +115,58 @@ $ git bisect view --stat
112
115
Bisect log and bisect replay
113
116
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
114
117
115
- The good/bad input is logged, and
118
+ After having marked revisions as good or bad, you issue the following
119
+ command to show what has been done so far:
116
120
117
121
------------
118
122
$ git bisect log
119
123
------------
120
124
121
- shows what you have done so far. You can truncate its output somewhere
122
- and save it in a file, and run
125
+ If you discover that you made a mistake in specifying the status of a
126
+ revision, you can save the output of this command to a file, edit it to
127
+ remove the incorrect entries, and then issue the following commands to
128
+ return to a corrected state:
123
129
124
130
------------
131
+ $ git bisect reset
125
132
$ git bisect replay that-file
126
133
------------
127
134
128
- if you find later you made a mistake telling good/bad about a
129
- revision.
130
-
131
- Avoiding to test a commit
135
+ Avoiding testing a commit
132
136
~~~~~~~~~~~~~~~~~~~~~~~~~
133
137
134
- If in a middle of bisect session, you know what the bisect suggested
135
- to try next is not a good one to test (e.g. the change the commit
138
+ If in the middle of a bisect session, you know that the next suggested
139
+ revision is not a good one to test (e.g. the change the commit
136
140
introduces is known not to work in your environment and you know it
137
141
does not have anything to do with the bug you are chasing), you may
138
- want to find a near-by commit and try that instead.
142
+ want to find a nearby commit and try that instead.
139
143
140
- It goes something like this :
144
+ For example :
141
145
142
146
------------
143
- $ git bisect good/bad # previous round was good/ bad.
147
+ $ git bisect good/bad # previous round was good or bad.
144
148
Bisecting: 337 revisions left to test after this
145
149
$ git bisect visualize # oops, that is uninteresting.
146
- $ git reset --hard HEAD~3 # try 3 revs before what
150
+ $ git reset --hard HEAD~3 # try 3 revisions before what
147
151
# was suggested
148
152
------------
149
153
150
- Then compile and test the one you chose to try. After that, tell
151
- bisect what the result was as usual.
154
+ Then compile and test the chosen revision. Afterwards the revision
155
+ is marked as good or bad in the usual manner .
152
156
153
157
Bisect skip
154
158
~~~~~~~~~~~~
155
159
156
- Instead of choosing by yourself a nearby commit, you may just want git
157
- to do it for you using :
160
+ Instead of choosing by yourself a nearby commit, you can ask git
161
+ to do it for you by issuing the command :
158
162
159
163
------------
160
164
$ git bisect skip # Current version cannot be tested
161
165
------------
162
166
163
167
But computing the commit to test may be slower afterwards and git may
164
- eventually not be able to tell the first bad among a bad and one or
165
- more "skip"ped commits.
168
+ eventually not be able to tell the first bad commit among a bad commit
169
+ and one or more skipped commits.
166
170
167
171
You can even skip a range of commits, instead of just one commit,
168
172
using the "'<commit1>'..'<commit2>'" notation. For example:
@@ -171,33 +175,34 @@ using the "'<commit1>'..'<commit2>'" notation. For example:
171
175
$ git bisect skip v2.5..v2.6
172
176
------------
173
177
174
- would mean that no commit between `v2.5` excluded and `v2.6` included
175
- can be tested.
178
+ The effect of this would be that no commit between `v2.5` excluded and
179
+ `v2.6` included could be tested.
176
180
177
- Note that if you want to also skip the first commit of a range you can
178
- use something like :
181
+ Note that if you also want to skip the first commit of the range you
182
+ would issue the command :
179
183
180
184
------------
181
185
$ git bisect skip v2.5 v2.5..v2.6
182
186
------------
183
187
184
- and the commit pointed to by `v2.5` will be skipped too.
188
+ This would cause the commits between `v2.5` included and `v2.6` included
189
+ to be skipped.
190
+
185
191
186
192
Cutting down bisection by giving more parameters to bisect start
187
193
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
188
194
189
- You can further cut down the number of trials if you know what part of
190
- the tree is involved in the problem you are tracking down, by giving
191
- paths parameters when you say `bisect start`, like this :
195
+ You can further cut down the number of trials, if you know what part of
196
+ the tree is involved in the problem you are tracking down, by specifying
197
+ path parameters when issuing the `bisect start` command :
192
198
193
199
------------
194
200
$ git bisect start -- arch/i386 include/asm-i386
195
201
------------
196
202
197
- If you know beforehand more than one good commits, you can narrow the
198
- bisect space down without doing the whole tree checkout every time you
199
- give good commits. You give the bad revision immediately after `start`
200
- and then you give all the good revisions you have:
203
+ If you know beforehand more than one good commit, you can narrow the
204
+ bisect space down by specifying all of the good commits immediately after
205
+ the bad commit when issuing the `bisect start` command:
201
206
202
207
------------
203
208
$ git bisect start v2.6.20-rc6 v2.6.20-rc4 v2.6.20-rc1 --
@@ -209,38 +214,38 @@ Bisect run
209
214
~~~~~~~~~~
210
215
211
216
If you have a script that can tell if the current source code is good
212
- or bad, you can automatically bisect using :
217
+ or bad, you can bisect by issuing the command :
213
218
214
219
------------
215
220
$ git bisect run my_script arguments
216
221
------------
217
222
218
- Note that the "run" script (`my_script` in the above example) should
219
- exit with code 0 in case the current source code is good. Exit with a
223
+ Note that the script (`my_script` in the above example) should
224
+ exit with code 0 if the current source code is good, and exit with a
220
225
code between 1 and 127 (inclusive), except 125, if the current
221
226
source code is bad.
222
227
223
- Any other exit code will abort the automatic bisect process. (A
224
- program that does "exit(-1)" leaves $? = 255, see exit(3) manual page,
225
- the value is chopped with "& 0377".)
228
+ Any other exit code will abort the bisect process. It should be noted
229
+ that a program that terminates via "exit(-1)" leaves $? = 255, ( see the
230
+ exit(3) manual page), as the value is chopped with "& 0377".
226
231
227
232
The special exit code 125 should be used when the current source code
228
- cannot be tested. If the "run" script exits with this code, the current
229
- revision will be skipped, see `git bisect skip` above.
233
+ cannot be tested. If the script exits with this code, the current
234
+ revision will be skipped ( see `git bisect skip` above) .
230
235
231
- You may often find that during bisect you want to have near-constant
232
- tweaks (e.g., s/#define DEBUG 0/#define DEBUG 1/ in a header file, or
233
- "revision that does not have this commit needs this patch applied to
234
- work around other problem this bisection is not interested in")
235
- applied to the revision being tested.
236
+ You may often find that during a bisect session you want to have
237
+ temporary modifications (e.g. s/#define DEBUG 0/#define DEBUG 1/ in a
238
+ header file, or "revision that does not have this commit needs this
239
+ patch applied to work around another problem this bisection is not
240
+ interested in") applied to the revision being tested.
236
241
237
242
To cope with such a situation, after the inner 'git bisect' finds the
238
- next revision to test, with the "run" script, you can apply that tweak
239
- before compiling, run the real test, and after the test decides if the
240
- revision (possibly with the needed tweaks ) passed the test, rewind the
241
- tree to the pristine state. Finally the "run" script can exit with
242
- the status of the real test to let the "git bisect run" command loop to
243
- determine the outcome.
243
+ next revision to test, the script can apply the patch
244
+ before compiling, run the real test, and afterwards decide if the
245
+ revision (possibly with the needed patch ) passed the test and then
246
+ rewind the tree to the pristine state. Finally the script should exit
247
+ with the status of the real test to let the "git bisect run" command loop
248
+ determine the eventual outcome of the bisect session .
244
249
245
250
EXAMPLES
246
251
--------
@@ -264,39 +269,39 @@ $ git bisect run make test # "make test" builds and tests
264
269
------------
265
270
$ cat ~/test.sh
266
271
#!/bin/sh
267
- make || exit 125 # this "skip"s broken builds
272
+ make || exit 125 # this skips broken builds
268
273
make test # "make test" runs the test suite
269
274
$ git bisect start v1.3 v1.1 -- # v1.3 is bad, v1.1 is good
270
275
$ git bisect run ~/test.sh
271
276
------------
272
277
+
273
278
Here we use a "test.sh" custom script. In this script, if "make"
274
- fails, we " skip" the current commit.
279
+ fails, we skip the current commit.
275
280
+
276
- It's safer to use a custom script outside the repo to prevent
281
+ It is safer to use a custom script outside the repository to prevent
277
282
interactions between the bisect, make and test processes and the
278
283
script.
279
284
+
280
- And "make test" should "exit 0", if the test suite passes, and
281
- "exit 1" (for example) otherwise.
285
+ "make test" should "exit 0", if the test suite passes, and
286
+ "exit 1" otherwise.
282
287
283
288
* Automatically bisect a broken test case:
284
289
+
285
290
------------
286
291
$ cat ~/test.sh
287
292
#!/bin/sh
288
- make || exit 125 # this "skip"s broken builds
293
+ make || exit 125 # this skips broken builds
289
294
~/check_test_case.sh # does the test case passes ?
290
295
$ git bisect start HEAD HEAD~10 -- # culprit is among the last 10
291
296
$ git bisect run ~/test.sh
292
297
------------
293
298
+
294
- Here "check_test_case.sh" should "exit 0", if the test case passes,
295
- and "exit 1" (for example) otherwise.
299
+ Here "check_test_case.sh" should "exit 0" if the test case passes,
300
+ and "exit 1" otherwise.
296
301
+
297
- It's safer if both "test.sh" and "check_test_case.sh" scripts are
298
- outside the repo to prevent interactions between the bisect, make and
299
- test processes and the scripts.
302
+ It is safer if both "test.sh" and "check_test_case.sh" scripts are
303
+ outside the repository to prevent interactions between the bisect,
304
+ make and test processes and the scripts.
300
305
301
306
* Automatically bisect a broken test suite:
302
307
+
0 commit comments