Skip to content

Commit 0c34735

Browse files
committed
Merge branch 'cc/maint-1.6.0-bisect-fix'
* cc/maint-1.6.0-bisect-fix: bisect: fix quoting TRIED revs when "bad" commit is also "skip"ped Conflicts: git-bisect.sh
2 parents 2d56a13 + 1b249ff commit 0c34735

2 files changed

Lines changed: 66 additions & 35 deletions

File tree

git-bisect.sh

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -290,56 +290,62 @@ filter_skipped() {
290290

291291
# Let's parse the output of:
292292
# "git rev-list --bisect-vars --bisect-all ..."
293-
eval "$_eval" | while read hash line
294-
do
295-
case "$VARS,$FOUND,$TRIED,$hash" in
296-
# We display some vars.
297-
1,*,*,*) echo "$hash $line" ;;
298-
299-
# Split line.
300-
,*,*,---*) ;;
301-
302-
# We had nothing to search.
293+
eval "$_eval" | {
294+
VARS= FOUND= TRIED=
295+
while read hash line
296+
do
297+
case "$VARS,$FOUND,$TRIED,$hash" in
298+
1,*,*,*)
299+
# "bisect_foo=bar" read from rev-list output.
300+
echo "$hash &&"
301+
;;
302+
,*,*,---*)
303+
# Separator
304+
;;
303305
,,,bisect_rev*)
304-
echo "bisect_rev="
306+
# We had nothing to search.
307+
echo "bisect_rev= &&"
305308
VARS=1
306309
;;
307-
308-
# We did not find a good bisect rev.
309-
# This should happen only if the "bad"
310-
# commit is also a "skip" commit.
311310
,,*,bisect_rev*)
312-
echo "bisect_rev=$TRIED"
311+
# We did not find a good bisect rev.
312+
# This should happen only if the "bad"
313+
# commit is also a "skip" commit.
314+
echo "bisect_rev='$TRIED' &&"
313315
VARS=1
314316
;;
315-
316-
# We are searching.
317317
,,*,*)
318+
# We are searching.
318319
TRIED="${TRIED:+$TRIED|}$hash"
319320
case "$_skip" in
320321
*$hash*) ;;
321322
*)
322-
echo "bisect_rev=$hash"
323-
echo "bisect_tried=\"$TRIED\""
323+
echo "bisect_rev=$hash &&"
324+
echo "bisect_tried='$TRIED' &&"
324325
FOUND=1
325326
;;
326327
esac
327328
;;
328-
329-
# We have already found a rev to be tested.
330-
,1,*,bisect_rev*) VARS=1 ;;
331-
,1,*,*) ;;
332-
333-
# ???
334-
*) die "filter_skipped error " \
335-
"VARS: '$VARS' " \
336-
"FOUND: '$FOUND' " \
337-
"TRIED: '$TRIED' " \
338-
"hash: '$hash' " \
339-
"line: '$line'"
340-
;;
341-
esac
342-
done
329+
,1,*,bisect_rev*)
330+
# We have already found a rev to be tested.
331+
VARS=1
332+
;;
333+
,1,*,*)
334+
;;
335+
*)
336+
# Unexpected input
337+
echo "die 'filter_skipped error'"
338+
die "filter_skipped error " \
339+
"VARS: '$VARS' " \
340+
"FOUND: '$FOUND' " \
341+
"TRIED: '$TRIED' " \
342+
"hash: '$hash' " \
343+
"line: '$line'"
344+
;;
345+
esac
346+
done
347+
echo ':'
348+
}
343349
}
344350

345351
exit_if_skipped_commits () {

t/t6030-bisect-porcelain.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,31 @@ test_expect_success 'bisect skip: cannot tell between 2 commits' '
224224
fi
225225
'
226226

227+
# $HASH1 is good, $HASH4 is both skipped and bad, we skip $HASH3
228+
# and $HASH2 is good,
229+
# so we should not be able to tell the first bad commit
230+
# among $HASH3 and $HASH4
231+
test_expect_success 'bisect skip: with commit both bad and skipped' '
232+
git bisect start &&
233+
git bisect skip &&
234+
git bisect bad &&
235+
git bisect good $HASH1 &&
236+
git bisect skip &&
237+
if git bisect good > my_bisect_log.txt
238+
then
239+
echo Oops, should have failed.
240+
false
241+
else
242+
test $? -eq 2 &&
243+
grep "first bad commit could be any of" my_bisect_log.txt &&
244+
! grep $HASH1 my_bisect_log.txt &&
245+
! grep $HASH2 my_bisect_log.txt &&
246+
grep $HASH3 my_bisect_log.txt &&
247+
grep $HASH4 my_bisect_log.txt &&
248+
git bisect reset
249+
fi
250+
'
251+
227252
# We want to automatically find the commit that
228253
# introduced "Another" into hello.
229254
test_expect_success \

0 commit comments

Comments
 (0)