From f0c5793b37a53992611968ab4a1d62a0e3edc2dd Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sat, 25 Feb 2012 18:34:26 +0100 Subject: 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: Jim Meyering Signed-off-by: Junio C Hamano --- t/t4150-am.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 't') diff --git a/t/t4150-am.sh b/t/t4150-am.sh index d7d9ccc1c8..03eee07ffb 100755 --- a/t/t4150-am.sh +++ b/t/t4150-am.sh @@ -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 -- cgit v1.2.1