Git - Bisect

From Training Material
Revision as of 10:04, 4 December 2012 by Bernard Szlachta (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
 # Initiallize repo
 cd /g
 mkdir /g/tmp
 cd tmp
 mkdir repo
 cd repo/
 git init  


  echo "exit 0" > code.sh
  git add code.sh; 
  git commit -a -m "c0"
  
  # Genereate 10 revision which do not spoil the script
  for i in $(seq 10) ; do   echo "# round 1 $i" >> code.sh ; git commit -a -m "c$i" ; done
  
  # Spoil the script
  echo "exit 1" > code.sh
  git commit -a -m "bug revision"
 
  # generate 20 revisions which do not spoil already spoiled script
  for i in $(seq 20) ; do   echo "# round 2 $i" >> code.sh ; git commit -a -m "c$i" ; done
 


 git bisect start
 git bisect bad
 # mark first revision as good
 git bisect good  6d34b 

 git bisect run bash code.sh
running bash code.sh
Bisecting: 7 revisions left to test after this (roughly 3 steps)
[65e896df0fb1a865e8678bc2145f1621b802acfd] c7
running bash code.sh
Bisecting: 3 revisions left to test after this (roughly 2 steps)
[480515f739bf6dd9a2a6ab47d8626aea805d4880] bug revision
running bash code.sh
Bisecting: 1 revision left to test after this (roughly 1 step)
[52de39416f0f93a1b95f744de05699baa85ab224] c9
running bash code.sh
Bisecting: 0 revisions left to test after this (roughly 0 steps)
[22ef2aaf18c69aa420534303ceeec2078154357c] c10
running bash code.sh
480515f739bf6dd9a2a6ab47d8626aea805d4880 is the first bad commit
commit 480515f739bf6dd9a2a6ab47d8626aea805d4880
Author: Your Name <you@example.com>
Date:   Tue Dec 4 00:02:09 2012 +0000

    bug revision

:100644 100644 68d815b9ee3a9b590f2be9db2adfe37d715f964f 379a4c986e3265e08e9da42c56ec747619c56a33 M	code.sh
bisect run success