@matheusbsbs / matheus-bagliano / commits / 737c74ee42
Fork 0

Bisect: refactor some logging into "bisect_write".

Also use "die" instead of "echo >&2 something ; exit 1". And simplify "bisect_replay". Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Christian Couder committed Oct 24, 2007 at 07:01 UTC 737c74ee4219a81ebb616262579f63ce2a3f9698
1 file changed +14 -33
git-bisect.sh
+14 -33
@@ -106,12 +106,11 @@ bisect_start() {
106 die "'$arg' does not appear to be a valid revision"
107 break
108 }
109 - if [ $bad_seen -eq 0 ]; then
110 - bad_seen=1
111 - bisect_write 'bad' "$rev"
112 - else
113 - bisect_write 'good' "$rev"
114 - fi
109 + case $bad_seen in
110 + 0) state='bad' ; bad_seen=1 ;;
111 + *) state='good' ;;
112 + esac
113 + bisect_write "$state" "$rev" 'nolog'
114 shift
115 ;;
116 esac
@@ -125,6 +124,7 @@ bisect_start() {
124 bisect_write() {
125 state="$1"
126 rev="$2"
127 + nolog="$3"
128 case "$state" in
129 bad) tag="$state" ;;
130 good|skip) tag="$state"-"$rev" ;;
@@ -132,6 +132,7 @@ bisect_write() {
132 esac
133 echo "$rev" >"$GIT_DIR/refs/bisect/$tag"
134 echo "# $state: "$(git show-branch $rev) >>"$GIT_DIR/BISECT_LOG"
135 + test -z "$nolog" && echo "git-bisect $state $rev" >>"$GIT_DIR/BISECT_LOG"
136 }
137
138 bisect_bad() {
@@ -145,7 +146,6 @@ bisect_bad() {
146 usage ;;
147 esac || exit
148 bisect_write 'bad' "$rev"
148 - echo "git-bisect bad $rev" >>"$GIT_DIR/BISECT_LOG"
149 bisect_auto_next
150 }
151
@@ -160,7 +160,6 @@ bisect_good() {
160 do
161 rev=$(git rev-parse --verify "$rev^{commit}") || exit
162 bisect_write 'good' "$rev"
163 - echo "git-bisect good $rev" >>"$GIT_DIR/BISECT_LOG"
163 done
164 bisect_auto_next
165 }
@@ -176,7 +175,6 @@ bisect_skip() {
175 do
176 rev=$(git rev-parse --verify "$rev^{commit}") || exit
177 bisect_write 'skip' "$rev"
179 - echo "git-bisect skip $rev" >>"$GIT_DIR/BISECT_LOG"
178 done
179 bisect_auto_next
180 }
@@ -352,10 +350,8 @@ bisect_reset() {
350 else
351 branch=master
352 fi ;;
355 - 1) git show-ref --verify --quiet -- "refs/heads/$1" || {
356 - echo >&2 "$1 does not seem to be a valid branch"
357 - exit 1
358 - }
353 + 1) git show-ref --verify --quiet -- "refs/heads/$1" ||
354 + die "$1 does not seem to be a valid branch"
355 branch="$1" ;;
356 *)
357 usage ;;
@@ -375,10 +371,7 @@ bisect_clean_state() {
371 }
372
373 bisect_replay () {
378 - test -r "$1" || {
379 - echo >&2 "cannot read $1 for replaying"
380 - exit 1
381 - }
374 + test -r "$1" || die "cannot read $1 for replaying"
375 bisect_reset
376 while read bisect command rev
377 do
@@ -386,23 +379,11 @@ bisect_replay () {
379 case "$command" in
380 start)
381 cmd="bisect_start $rev"
389 - eval "$cmd"
390 - ;;
391 - good)
392 - bisect_write 'good' "$rev"
393 - echo "git-bisect good $rev" >>"$GIT_DIR/BISECT_LOG"
394 - ;;
395 - bad)
396 - bisect_write 'bad' "$rev"
397 - echo "git-bisect bad $rev" >>"$GIT_DIR/BISECT_LOG"
398 - ;;
399 - skip)
400 - bisect_write 'skip' "$rev"
401 - echo "git-bisect skip $rev" >>"$GIT_DIR/BISECT_LOG"
402 - ;;
382 + eval "$cmd" ;;
383 + good|bad|skip)
384 + bisect_write "$command" "$rev" ;;
385 *)
404 - echo >&2 "?? what are you talking about?"
405 - exit 1 ;;
386 + die "?? what are you talking about?" ;;
387 esac
388 done <"$1"
389 bisect_auto_next