Skip to content

Commit 9675ecf

Browse files
authored
Merge pull request #192 from UCL/clean_bisect
Updates git bisect instructions to make them more readable
2 parents c7ec43d + 913e68b commit 9675ecf

File tree

1 file changed

+57
-45
lines changed

1 file changed

+57
-45
lines changed

ch02git/14Bisect.ipynb

Lines changed: 57 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"source": [
6363
"%%bash\n",
6464
"rm -rf bisectdemo\n",
65-
"git clone [email protected]:shawnsi/bisectdemo.git"
65+
"git clone [email protected]:UCL-RITS/bisectdemo.git"
6666
]
6767
},
6868
{
@@ -137,13 +137,12 @@
137137
"name": "stderr",
138138
"output_type": "stream",
139139
"text": [
140-
"error: branch 'buggy' not found.\n",
141140
"Switched to a new branch 'buggy'\n"
142141
]
143142
}
144143
],
145144
"source": [
146-
"%%bash \n",
145+
"%%bash\n",
147146
"./breakme.sh > break_output"
148147
]
149148
},
@@ -165,15 +164,28 @@
165164
},
166165
"outputs": [
167166
{
168-
"ename": "SyntaxError",
169-
"evalue": "invalid syntax (<ipython-input-6-69f578907137>, line 1)",
167+
"name": "stderr",
168+
"output_type": "stream",
169+
"text": [
170+
"Traceback (most recent call last):\n",
171+
" File \"squares.py\", line 9, in <module>\n",
172+
" print(integer**2)\n",
173+
"TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int'\n"
174+
]
175+
},
176+
{
177+
"ename": "CalledProcessError",
178+
"evalue": "Command 'b'python squares.py 2 #\\xc2\\xa0Error message\\n'' returned non-zero exit status 1.",
170179
"output_type": "error",
171180
"traceback": [
172-
"\u001b[0;36m File \u001b[0;32m\"<ipython-input-6-69f578907137>\"\u001b[0;36m, line \u001b[0;32m1\u001b[0m\n\u001b[0;31m python squares.py 2 # Error message\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n"
181+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
182+
"\u001b[0;31mCalledProcessError\u001b[0m Traceback (most recent call last)",
183+
"\u001b[0;31mCalledProcessError\u001b[0m: Command 'b'python squares.py 2 #\\xc2\\xa0Error message\\n'' returned non-zero exit status 1."
173184
]
174185
}
175186
],
176187
"source": [
188+
"%%bash\n",
177189
"python squares.py 2 # Error message"
178190
]
179191
},
@@ -316,8 +328,10 @@
316328
"cell_type": "markdown",
317329
"metadata": {},
318330
"source": [
331+
"Stop the bisect process with:\n",
332+
"\n",
319333
"``` bash\n",
320-
"git bisect end\n",
334+
"git bisect reset\n",
321335
"```"
322336
]
323337
},
@@ -327,7 +341,9 @@
327341
"source": [
328342
"### Solving automatically\n",
329343
"\n",
330-
"If we have an appropriate unit test, we can do all this automatically:"
344+
"If we have an appropriate unit test, we can do all this automatically:\n",
345+
"\n",
346+
"(*NOTE*: You don't need [to redirect the `stderr` and `stdout`](https://linuxize.com/post/bash-redirect-stderr-stdout/) (with `&>`) of `git bisect run` to a file when running these commands outside a jupyter notebook (i.e., on a shell). This is done here so the errors appears with the right commits)"
331347
]
332348
},
333349
{
@@ -351,77 +367,72 @@
351367
"output_type": "stream",
352368
"text": [
353369
"Bisecting: 500 revisions left to test after this (roughly 9 steps)\n",
354-
"[f85561dbe54b69fc7f037e3fd1b742b7395726b5] Comment 500\n",
370+
"[8ab337c43ca34bf91ab17cc55890be57d3567c82] Comment 500\n",
355371
"running python squares.py 2\n",
356372
"4\n",
357373
"Bisecting: 250 revisions left to test after this (roughly 8 steps)\n",
358-
"[1842ee96db81d26ce5c00a4b8750bd19ec380bfc] Comment 749\n",
374+
"[d25fb2ac5a0ed2e9474bec5a32e52eaf6f96ff6c] Comment 749\n",
359375
"running python squares.py 2\n",
376+
"Traceback (most recent call last):\n",
377+
" File \"squares.py\", line 9, in <module>\n",
378+
" print(integer**2)\n",
379+
"TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int'\n",
360380
"Bisecting: 124 revisions left to test after this (roughly 7 steps)\n",
361-
"[749d1352b870cc169bc3c6e9e15c69d191a2a66e] Comment 625\n",
381+
"[cc0d01b552be8314dc9734c78b3363b620cb325c] Comment 624\n",
362382
"running python squares.py 2\n",
363-
"4\n",
383+
"Traceback (most recent call last):\n",
384+
" File \"squares.py\", line 9, in <module>\n",
385+
" print(integer**2)\n",
386+
"TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int'\n",
364387
"Bisecting: 62 revisions left to test after this (roughly 6 steps)\n",
365-
"[150773712a2e9e8a371f33429abf9826d3a2b65e] Comment 687\n",
388+
"[4b46a6e37c388d260d61409e51864ae77ba19d6d] Comment 562\n",
366389
"running python squares.py 2\n",
367390
"4\n",
368391
"Bisecting: 31 revisions left to test after this (roughly 5 steps)\n",
369-
"[0e12bcd2d685904abf22431381000c68ca0af230] Comment 717\n",
392+
"[5eda263aaa5d0914b5871f546db26b7914895271] Breaking argument type\n",
370393
"running python squares.py 2\n",
394+
"Traceback (most recent call last):\n",
395+
" File \"squares.py\", line 9, in <module>\n",
396+
" print(integer**2)\n",
397+
"TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int'\n",
371398
"Bisecting: 15 revisions left to test after this (roughly 4 steps)\n",
372-
"[cd59a9f75102f1b49863ad424fc35dc802522ccd] Comment 702\n",
399+
"[c9097be29af1b3437905feb0969669820ea81283] Comment 577\n",
373400
"running python squares.py 2\n",
374401
"4\n",
375402
"Bisecting: 7 revisions left to test after this (roughly 3 steps)\n",
376-
"[a105ae052d898733015676ac6709b1ffe88ed8bd] Comment 709\n",
403+
"[8021453f7f6fde4319a21337968832be1cc4151a] Comment 585\n",
377404
"running python squares.py 2\n",
405+
"4\n",
378406
"Bisecting: 3 revisions left to test after this (roughly 2 steps)\n",
379-
"[08508dd54091baa9e00c3599cb83cd0cda5b5837] Comment 706\n",
407+
"[f373b49b6545427ce00c991ca112bdc65d712fbf] Comment 589\n",
380408
"running python squares.py 2\n",
381409
"4\n",
382410
"Bisecting: 1 revision left to test after this (roughly 1 step)\n",
383-
"[7ced4763b6ab1600aab31d18fd2592186fd78b89] Comment 707\n",
411+
"[66f6530a9d0a459fc0ba132c17451d281449ffee] Comment 591\n",
384412
"running python squares.py 2\n",
413+
"4\n",
385414
"Bisecting: 0 revisions left to test after this (roughly 0 steps)\n",
386-
"[ebb3f4a5f4000c28bbc12d4d0187bbdad3d92241] Breaking argument type\n",
415+
"[1694ac7328d0a379362dec982d8d3afe14cc98b8] Comment 592\n",
387416
"running python squares.py 2\n",
388-
"ebb3f4a5f4000c28bbc12d4d0187bbdad3d92241 is the first bad commit\n",
389-
"commit ebb3f4a5f4000c28bbc12d4d0187bbdad3d92241\n",
417+
"4\n",
418+
"5eda263aaa5d0914b5871f546db26b7914895271 is the first bad commit\n",
419+
"commit 5eda263aaa5d0914b5871f546db26b7914895271\n",
390420
"Author: Shawn Siefkas <[email protected]>\n",
391421
"Date: Thu Nov 14 09:23:55 2013 -0600\n",
392422
"\n",
393423
" Breaking argument type\n",
394424
"\n",
395-
":100644 100644 430222f37d6aad3ba2b7f235991473e680c7e4d8 03bc808166ca5cd0a8cca51cfb522e0724a31bc6 M\tsquares.py\n",
425+
" squares.py | 2 +-\n",
426+
" 1 file changed, 1 insertion(+), 1 deletion(-)\n",
396427
"bisect run success\n"
397428
]
398429
},
399430
{
400431
"name": "stderr",
401432
"output_type": "stream",
402433
"text": [
403-
"Previous HEAD position was f85561d... Comment 500\n",
404-
"Switched to branch 'buggy'\n",
405-
"Traceback (most recent call last):\n",
406-
" File \"squares.py\", line 9, in <module>\n",
407-
" print(integer**2)\n",
408-
"TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int'\n",
409-
"Traceback (most recent call last):\n",
410-
" File \"squares.py\", line 9, in <module>\n",
411-
" print(integer**2)\n",
412-
"TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int'\n",
413-
"Traceback (most recent call last):\n",
414-
" File \"squares.py\", line 9, in <module>\n",
415-
" print(integer**2)\n",
416-
"TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int'\n",
417-
"Traceback (most recent call last):\n",
418-
" File \"squares.py\", line 9, in <module>\n",
419-
" print(integer**2)\n",
420-
"TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int'\n",
421-
"Traceback (most recent call last):\n",
422-
" File \"squares.py\", line 9, in <module>\n",
423-
" print(integer**2)\n",
424-
"TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int'\n"
434+
"Previous HEAD position was 1694ac7 Comment 592\n",
435+
"Switched to branch 'buggy'\n"
425436
]
426437
}
427438
],
@@ -430,7 +441,8 @@
430441
"git bisect start\n",
431442
"git bisect bad HEAD # We know the current state is broken\n",
432443
"git bisect good master # We know master is good\n",
433-
"git bisect run python squares.py 2"
444+
"git bisect run python squares.py 2 &> gitbisect.out\n",
445+
"cat gitbisect.out"
434446
]
435447
},
436448
{

0 commit comments

Comments
 (0)