提交 f0c5793b 编写于 作者: J Jim Meyering 提交者: Junio C Hamano

am: don't infloop for an empty input file

git-am.sh's check_patch_format function would attempt to preview
the patch to guess its format, but would go into an infinite loop
when the patch file happened to be empty.  The solution: exit the
loop when "read" fails, not when the line var, "$l1" becomes empty.
Signed-off-by: NJim Meyering <meyering@redhat.com>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 ad687b44
......@@ -201,7 +201,7 @@ check_patch_format () {
l1=
while test -z "$l1"
do
read l1
read l1 || break
done
read l2
read l3
......
......@@ -495,4 +495,14 @@ test_expect_success 'am -q is quiet' '
! test -s output.out
'
test_expect_success 'am empty-file does not infloop' '
rm -fr .git/rebase-apply &&
git reset --hard &&
touch empty-file &&
test_tick &&
{ git am empty-file > actual 2>&1 && false || :; } &&
echo Patch format detection failed. >expected &&
test_cmp expected actual
'
test_done
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册