Skip to content

Commit 3e186ef

Browse files
committed
Merge branch 'cc/maint-1.6.0-bisect-fix' into maint-1.6.0
* cc/maint-1.6.0-bisect-fix: bisect: fix another instance of eval'ed string bisect: fix quoting TRIED revs when "bad" commit is also "skip"ped
2 parents fa711bc + cce074a commit 3e186ef

File tree

2 files changed

+73
-36
lines changed

2 files changed

+73
-36
lines changed

git-bisect.sh

Lines changed: 48 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -263,62 +263,74 @@ filter_skipped() {
263263
_skip="$2"
264264

265265
if [ -z "$_skip" ]; then
266-
eval_rev_list "$_eval"
266+
eval_rev_list "$_eval" | {
267+
while read line
268+
do
269+
echo "$line &&"
270+
done
271+
echo ':'
272+
}
267273
return
268274
fi
269275

270276
# Let's parse the output of:
271277
# "git rev-list --bisect-vars --bisect-all ..."
272-
eval_rev_list "$_eval" | while read hash line
273-
do
274-
case "$VARS,$FOUND,$TRIED,$hash" in
275-
# We display some vars.
276-
1,*,*,*) echo "$hash $line" ;;
277-
278-
# Split line.
279-
,*,*,---*) ;;
280-
281-
# We had nothing to search.
278+
eval_rev_list "$_eval" | {
279+
VARS= FOUND= TRIED=
280+
while read hash line
281+
do
282+
case "$VARS,$FOUND,$TRIED,$hash" in
283+
1,*,*,*)
284+
# "bisect_foo=bar" read from rev-list output.
285+
echo "$hash &&"
286+
;;
287+
,*,*,---*)
288+
# Separator
289+
;;
282290
,,,bisect_rev*)
283-
echo "bisect_rev="
291+
# We had nothing to search.
292+
echo "bisect_rev= &&"
284293
VARS=1
285294
;;
286-
287-
# We did not find a good bisect rev.
288-
# This should happen only if the "bad"
289-
# commit is also a "skip" commit.
290295
,,*,bisect_rev*)
291-
echo "bisect_rev=$TRIED"
296+
# We did not find a good bisect rev.
297+
# This should happen only if the "bad"
298+
# commit is also a "skip" commit.
299+
echo "bisect_rev='$TRIED' &&"
292300
VARS=1
293301
;;
294-
295-
# We are searching.
296302
,,*,*)
303+
# We are searching.
297304
TRIED="${TRIED:+$TRIED|}$hash"
298305
case "$_skip" in
299306
*$hash*) ;;
300307
*)
301-
echo "bisect_rev=$hash"
302-
echo "bisect_tried=\"$TRIED\""
308+
echo "bisect_rev=$hash &&"
309+
echo "bisect_tried='$TRIED' &&"
303310
FOUND=1
304311
;;
305312
esac
306313
;;
307-
308-
# We have already found a rev to be tested.
309-
,1,*,bisect_rev*) VARS=1 ;;
310-
,1,*,*) ;;
311-
312-
# ???
313-
*) die "filter_skipped error " \
314-
"VARS: '$VARS' " \
315-
"FOUND: '$FOUND' " \
316-
"TRIED: '$TRIED' " \
317-
"hash: '$hash' " \
318-
"line: '$line'"
319-
;;
320-
esac
321-
done
314+
,1,*,bisect_rev*)
315+
# We have already found a rev to be tested.
316+
VARS=1
317+
;;
318+
,1,*,*)
319+
;;
320+
*)
321+
# Unexpected input
322+
echo "die 'filter_skipped error'"
323+
die "filter_skipped error " \
324+
"VARS: '$VARS' " \
325+
"FOUND: '$FOUND' " \
326+
"TRIED: '$TRIED' " \
327+
"hash: '$hash' " \
328+
"line: '$line'"
329+
;;
330+
esac
331+
done
332+
echo ':'
333+
}
322334
}
323335

324336
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)