@matheusbsbs / matheus-bagliano / commits / fce0499fad
Fork 0

Bisect reset: do nothing when not bisecting.

Before this patch, using "git bisect reset" when not bisecting did a "git checkout master" for no good reason. This also happened using "git bisect replay" when not bisecting because "bisect_replay" starts by calling "bisect_reset". Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Christian Couder committed Nov 20, 2007 at 06:39 UTC fce0499fad13815d936c1068b7a064030f543b3d
2 files changed +30 -1
git-bisect.sh
+4
@@ -328,6 +328,10 @@ bisect_visualize() {
328 }
329
330 bisect_reset() {
331 + test -f "$GIT_DIR/BISECT_NAMES" || {
332 + echo "We are not bisecting."
333 + return
334 + }
335 case "$#" in
336 0) if [ -s "$GIT_DIR/head-name" ]; then
337 branch=`cat "$GIT_DIR/head-name"`
t/t6030-bisect-porcelain.sh
+26 -1
@@ -71,6 +71,31 @@ test_expect_success 'bisect start with one bad and good' '
71 git bisect next
72 '
73
74 +test_expect_success 'bisect reset: back in the master branch' '
75 + git bisect reset &&
76 + echo "* master" > branch.expect &&
77 + git branch > branch.output &&
78 + cmp branch.expect branch.output
79 +'
80 +
81 +test_expect_success 'bisect reset: back in another branch' '
82 + git checkout -b other &&
83 + git bisect start &&
84 + git bisect good $HASH1 &&
85 + git bisect bad $HASH3 &&
86 + git bisect reset &&
87 + echo " master" > branch.expect &&
88 + echo "* other" >> branch.expect &&
89 + git branch > branch.output &&
90 + cmp branch.expect branch.output
91 +'
92 +
93 +test_expect_success 'bisect reset when not bisecting' '
94 + git bisect reset &&
95 + git branch > branch.output &&
96 + cmp branch.expect branch.output
97 +'
98 +
99 test_expect_success 'bisect reset removes packed refs' '
100 git bisect reset &&
101 git bisect start &&
@@ -179,7 +204,7 @@ test_expect_success 'bisect skip: add line and then a new test' '
204 git bisect skip &&
205 git bisect good > my_bisect_log.txt &&
206 grep "$HASH5 is first bad commit" my_bisect_log.txt &&
182 - git bisect log > log_to_replay.txt
207 + git bisect log > log_to_replay.txt &&
208 git bisect reset
209 '
210