Skip to content

Commit d48c5d5

Browse files
pks-tgitster
authored andcommitted
t9300: work around partial read bug in Dash v0.5.13
When executing t9300 with Dash v0.5.13.1 we can see that the test hangs completely with the following (condensed) trace: git fast-import + error=1 + read output + cat input + echo checkpoint + echo progress checkpoint + test rogress checkpoint = progress checkpoint + test rogress checkpoint = UNEXPECTED + echo cruft: rogress checkpoint cruft: rogress checkpoint + read output + test = progress checkpoint + test = UNEXPECTED + echo cruft: cruft: + read output Basically, what's happening here is that we spawn git-fast-import(1) and wait for it to output a certain string, "progress checkpoint". Curiously though, what we end up reading is "rogress checkpoint" -- so the first byte of the expected string is missing. Same as in the preceding commit, this seems to be a bug in Dash itself that bisects to c5bf970 (expand: Add multi-byte support to pmatch, 2024-06-02). But other than in the preceding commit, this bug has already been fixed upstream in 079059a (input: Fix heap-buffer-overflow in preadbuffer on long lines, 2026-02-11), which is part of v0.5.13.2. For now though, work around the bug by waiting for the expected output in a different way. There is no good reason why one version should work better than the other, but at least the new version doesn't exhibit the bug. And, if you ask me, it's also slightly easier to read. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 0c8424c commit d48c5d5

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

t/t9300-fast-import.sh

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3635,25 +3635,21 @@ background_import_then_checkpoint () {
36353635
echo "progress checkpoint"
36363636
) >&8 &
36373637

3638-
error=1 ;# assume the worst
3639-
while read output <&9
3640-
do
3641-
if test "$output" = "progress checkpoint"
3642-
then
3643-
error=0
3644-
break
3645-
elif test "$output" = "UNEXPECTED"
3646-
then
3647-
break
3648-
fi
3649-
# otherwise ignore cruft
3650-
echo >&2 "cruft: $output"
3651-
done
3638+
last=$(
3639+
while read output <&9
3640+
do
3641+
if test "$output" = "progress checkpoint" || test "$output" = "UNEXPECTED"
3642+
then
3643+
echo "$output"
3644+
break
3645+
else
3646+
# otherwise ignore cruft
3647+
echo >&2 "cruft: $output"
3648+
fi
3649+
done
3650+
)
36523651

3653-
if test $error -eq 1
3654-
then
3655-
false
3656-
fi
3652+
test "$last" = "progress checkpoint"
36573653
}
36583654

36593655
background_import_still_running () {

0 commit comments

Comments
 (0)