On Thu, Sep 28, 2017 at 5:59 AM, Adam Dinwoodie <[email protected]> wrote:
> On Wed, Sep 27, 2017 at 10:07:41PM -0700, Eric Rannaud wrote:
>>
>> Also adding the necessary PIPE prereq, as pointed out by Ramsay Jones.
>
> Cygwin doesn't have the PIPE prereq; I've just confirmed that the
> previous version of this patch has t9300 failing on Cygwin, but this
> version passes.
What's the preferred solution here? I can avoid using named pipes entirely:
read_checkpoint () {
if read output
then
if ! test "$output" = "progress checkpoint"
then
echo >&2 "no progress checkpoint received:
$output"
echo 1 > V.result
else
echo 0 > V.result
fi
else
echo >&2 "failed to read fast-import output"
echo 1 > V.result
fi
}
# The commands in input_file should not produce any output on the file
# descriptor set with --cat-blob-fd (or stdout if unspecified).
#
# To make sure you're observing the side effects of checkpoint *before*
# fast-import terminates (and thus writes out its state), check that the
# fast-import process is still running using
background_import_still_running
# *after* evaluating the test conditions.
background_import_then_checkpoint () {
options=$1
input_file=$2
rm -f V.result
( cat "$input_file"
echo "checkpoint"
echo "progress checkpoint"
sleep 3600 &
echo $! >V.pid
wait ) | git fast-import $options | read_checkpoint &
# We don't mind if the pipeline has already died by the time
the test
# ends.
test_when_finished "kill $(cat V.pid) || true"
while ! test -f V.result
do
# Try to sleep less than a second, if supported.
sleep .1 2>/dev/null || sleep 1
done
return $(cat V.result)
}
Do we like this better?