Skip to content

Commit 42ba5ee

Browse files
chriscoolgitster
authored andcommitted
bisect: print an error message when "git rev-list --bisect-vars" fails
Before this patch no error was printed when "git rev-list --bisect-vars" failed. This can happen when bad and good revs are mistaken. This patch prints an error message on stderr that describe the likely failure cause. Signed-off-by: Christian Couder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ee831f7 commit 42ba5ee

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

git-bisect.sh

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,18 +220,33 @@ bisect_auto_next() {
220220
bisect_next_check && bisect_next || :
221221
}
222222

223+
eval_rev_list() {
224+
_eval="$1"
225+
226+
eval $_eval
227+
res=$?
228+
229+
if [ $res -ne 0 ]; then
230+
echo >&2 "'git rev-list --bisect-vars' failed:"
231+
echo >&2 "maybe you mistake good and bad revs?"
232+
exit $res
233+
fi
234+
235+
return $res
236+
}
237+
223238
filter_skipped() {
224239
_eval="$1"
225240
_skip="$2"
226241

227242
if [ -z "$_skip" ]; then
228-
eval $_eval
243+
eval_rev_list "$_eval"
229244
return
230245
fi
231246

232247
# Let's parse the output of:
233248
# "git rev-list --bisect-vars --bisect-all ..."
234-
eval $_eval | while read hash line
249+
eval_rev_list "$_eval" | while read hash line
235250
do
236251
case "$VARS,$FOUND,$TRIED,$hash" in
237252
# We display some vars.

t/t6030-bisect-porcelain.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,13 @@ test_expect_success 'bisect refuses to start if branch new-bisect exists' '
302302
git branch -d new-bisect
303303
'
304304

305+
test_expect_success 'bisect errors out if bad and good are mistaken' '
306+
git bisect reset &&
307+
test_must_fail git bisect start $HASH2 $HASH4 2> rev_list_error &&
308+
grep "mistake good and bad" rev_list_error &&
309+
git bisect reset
310+
'
311+
305312
#
306313
#
307314
test_done

0 commit comments

Comments
 (0)