debian-mirror-gitlab/doc/university/training/topics/bisect.md

74 lines
1.3 KiB
Markdown
Raw Normal View History

2018-03-17 18:26:18 +05:30
---
comments: false
---
2019-02-15 15:39:39 +05:30
# Bisect
2017-08-17 22:00:37 +05:30
- Find a commit that introduced a bug
- Works through a process of elimination
2018-11-20 20:47:30 +05:30
- Specify a known good and bad revision to begin
2017-08-17 22:00:37 +05:30
2019-10-12 21:52:04 +05:30
## Bisect sample workflow
2017-08-17 22:00:37 +05:30
1. Start the bisect process
2019-02-15 15:39:39 +05:30
1. Enter the bad revision (usually latest commit)
1. Enter a known good revision (commit/branch)
1. Run code to see if bug still exists
1. Tell bisect the result
1. Repeat the previous 2 items until you find the offending commit
2017-08-17 22:00:37 +05:30
## Setup
2019-09-04 21:01:54 +05:30
```sh
2017-08-17 22:00:37 +05:30
mkdir bisect-ex
cd bisect-ex
touch index.html
git add -A
git commit -m "starting out"
vi index.html
# Add all good
git add -A
git commit -m "second commit"
vi index.html
# Add all good 2
git add -A
git commit -m "third commit"
vi index.html
```
2019-09-04 21:01:54 +05:30
```sh
2017-08-17 22:00:37 +05:30
# Add all good 3
git add -A
git commit -m "fourth commit"
vi index.html
# This looks bad
git add -A
git commit -m "fifth commit"
vi index.html
# Really bad
git add -A
git commit -m "sixth commit"
vi index.html
# again just bad
git add -A
git commit -m "seventh commit"
```
## Commands
2019-09-04 21:01:54 +05:30
```sh
2017-08-17 22:00:37 +05:30
git bisect start
# Test your code
git bisect bad
git bisect next
# Say yes to the warning
# Test
git bisect good
# Test
git bisect bad
# Test
git bisect good
# done
git bisect reset
```