@matheusbsbs / matheus-bagliano / commits / 55624f9af4
Fork 0

Bisect: refactor "bisect_write_*" functions.

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 55624f9af49733ca6ae4abc3cd21e0f9a4f9f486
1 file changed +20 -26
git-bisect.sh
+20 -26
@@ -108,9 +108,9 @@ bisect_start() {
108 }
109 if [ $bad_seen -eq 0 ]; then
110 bad_seen=1
111 - bisect_write_bad "$rev"
111 + bisect_write 'bad' "$rev"
112 else
113 - bisect_write_good "$rev"
113 + bisect_write 'good' "$rev"
114 fi
115 shift
116 ;;
@@ -122,6 +122,18 @@ bisect_start() {
122 bisect_auto_next
123 }
124
125 +bisect_write() {
126 + state="$1"
127 + rev="$2"
128 + case "$state" in
129 + bad) tag="$state" ;;
130 + good|skip) tag="$state"-"$rev" ;;
131 + *) die "Bad bisect_write argument: $state" ;;
132 + esac
133 + echo "$rev" >"$GIT_DIR/refs/bisect/$tag"
134 + echo "# $state: "$(git show-branch $rev) >>"$GIT_DIR/BISECT_LOG"
135 +}
136 +
137 bisect_bad() {
138 bisect_autostart
139 case "$#" in
@@ -132,17 +144,11 @@ bisect_bad() {
144 *)
145 usage ;;
146 esac || exit
135 - bisect_write_bad "$rev"
147 + bisect_write 'bad' "$rev"
148 echo "git-bisect bad $rev" >>"$GIT_DIR/BISECT_LOG"
149 bisect_auto_next
150 }
151
140 -bisect_write_bad() {
141 - rev="$1"
142 - echo "$rev" >"$GIT_DIR/refs/bisect/bad"
143 - echo "# bad: "$(git show-branch $rev) >>"$GIT_DIR/BISECT_LOG"
144 -}
145 -
152 bisect_good() {
153 bisect_autostart
154 case "$#" in
@@ -153,18 +159,12 @@ bisect_good() {
159 for rev in $revs
160 do
161 rev=$(git rev-parse --verify "$rev^{commit}") || exit
156 - bisect_write_good "$rev"
162 + bisect_write 'good' "$rev"
163 echo "git-bisect good $rev" >>"$GIT_DIR/BISECT_LOG"
164 done
165 bisect_auto_next
166 }
167
162 -bisect_write_good() {
163 - rev="$1"
164 - echo "$rev" >"$GIT_DIR/refs/bisect/good-$rev"
165 - echo "# good: "$(git show-branch $rev) >>"$GIT_DIR/BISECT_LOG"
166 -}
167 -
168 bisect_skip() {
169 bisect_autostart
170 case "$#" in
@@ -175,18 +175,12 @@ bisect_skip() {
175 for rev in $revs
176 do
177 rev=$(git rev-parse --verify "$rev^{commit}") || exit
178 - bisect_write_skip "$rev"
178 + bisect_write 'skip' "$rev"
179 echo "git-bisect skip $rev" >>"$GIT_DIR/BISECT_LOG"
180 done
181 bisect_auto_next
182 }
183
184 -bisect_write_skip() {
185 - rev="$1"
186 - echo "$rev" >"$GIT_DIR/refs/bisect/skip-$rev"
187 - echo "# skip: "$(git show-branch $rev) >>"$GIT_DIR/BISECT_LOG"
188 -}
189 -
184 bisect_next_check() {
185 missing_good= missing_bad=
186 git show-ref -q --verify refs/bisect/bad || missing_bad=t
@@ -395,15 +389,15 @@ bisect_replay () {
389 eval "$cmd"
390 ;;
391 good)
398 - bisect_write_good "$rev"
392 + bisect_write 'good' "$rev"
393 echo "git-bisect good $rev" >>"$GIT_DIR/BISECT_LOG"
394 ;;
395 bad)
402 - bisect_write_bad "$rev"
396 + bisect_write 'bad' "$rev"
397 echo "git-bisect bad $rev" >>"$GIT_DIR/BISECT_LOG"
398 ;;
399 skip)
406 - bisect_write_skip "$rev"
400 + bisect_write 'skip' "$rev"
401 echo "git-bisect skip $rev" >>"$GIT_DIR/BISECT_LOG"
402 ;;
403 *)