{"thread":{"id":"24198","subject":"[PATCH] t4027,4041: Use test -s to test for an empty file","startedAt":"2010-06-25T17:20:48Z","lastAt":"2010-06-25T17:20:48Z","messageCount":1,"participants":["Brian Gernhardt"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"144255","messageId":"20100625172047.GA16172@hermes","threadId":"24198","inReplyTo":null,"subject":"[PATCH] t4027,4041: Use test -s to test for an empty file","fromName":"Brian Gernhardt","fromEmail":"brian@silverinsanity.com","sentAt":"2010-06-25T17:20:48Z","receivedAt":"2010-06-25T17:20:48Z","isPatch":true,"sender":{"key":"brian@silverinsanity.com","avatar":null},"body":"The tests used a mixture of 'echo -n' (which is non-portable) and either\ntest_cmp or diff to check if a file is empty.  The much easier and portable\nmethod to check for an empty file is '! test -s'\n\nWhile we're in t4027, there was an excess test_done.  Remove it.\n\nSigned-off-by: Brian Gernhardt <brian@gernhardtsoftware.com>\n---\n\n Changes since v2:\n  - extra trailing dashes removed (noticed by Brandon Casey)\n  - extra test_done removed (noticed by Junio C Hamano)\n\n t/t4027-diff-submodule.sh        |   12 ++++++------\n t/t4041-diff-submodule-option.sh |   14 +++++++-------\n 2 files changed, 13 insertions(+), 13 deletions(-)\n\ndiff --git a/t/t4027-diff-submodule.sh b/t/t4027-diff-submodule.sh\nindex 559b41e..1bd8e5e 100755\n--- a/t/t4027-diff-submodule.sh\n+++ b/t/t4027-diff-submodule.sh\n@@ -105,15 +105,15 @@ test_expect_success 'git diff HEAD with dirty submodule (work tree, refs match)'\n \texpect_from_to >expect.body $subprev $subprev-dirty &&\n \ttest_cmp expect.body actual.body &&\n \tgit diff --ignore-submodules HEAD >actual2 &&\n-\techo -n \"\" | test_cmp - actual2 &&\n+\t! test -s actual2 &&\n \tgit diff --ignore-submodules=untracked HEAD >actual3 &&\n \tsed -e \"1,/^@@/d\" actual3 >actual3.body &&\n \texpect_from_to >expect.body $subprev $subprev-dirty &&\n \ttest_cmp expect.body actual3.body &&\n \tgit diff --ignore-submodules=dirty HEAD >actual4 &&\n-\techo -n \"\" | test_cmp - actual4\n+\t! test -s actual4\n '\n-test_done\n+\n test_expect_success 'git diff HEAD with dirty submodule (index, refs match)' '\n \t(\n \t\tcd sub &&\n@@ -139,11 +139,11 @@ test_expect_success 'git diff HEAD with dirty submodule (untracked, refs match)'\n \texpect_from_to >expect.body $subprev $subprev-dirty &&\n \ttest_cmp expect.body actual.body &&\n \tgit diff --ignore-submodules=all HEAD >actual2 &&\n-\techo -n \"\" | test_cmp - actual2 &&\n+\t! test -s actual2 &&\n \tgit diff --ignore-submodules=untracked HEAD >actual3 &&\n-\techo -n \"\" | test_cmp - actual3 &&\n+\t! test -s actual3 &&\n \tgit diff --ignore-submodules=dirty HEAD >actual4 &&\n-\techo -n \"\" | test_cmp - actual4\n+\t! test -s actual4\n '\n \n test_expect_success 'git diff (empty submodule dir)' '\ndiff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh\nindex f44b906..8e391cf 100755\n--- a/t/t4041-diff-submodule-option.sh\n+++ b/t/t4041-diff-submodule-option.sh\n@@ -207,17 +207,17 @@ EOF\n \n test_expect_success 'submodule contains untracked content (untracked ignored)' \"\n \tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n-\techo -n '' | diff actual -\n+\t! test -s actual\n \"\n \n test_expect_success 'submodule contains untracked content (dirty ignored)' \"\n \tgit diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&\n-\techo -n '' | diff actual -\n+\t! test -s actual\n \"\n \n test_expect_success 'submodule contains untracked content (all ignored)' \"\n \tgit diff-index -p --ignore-submodules=all --submodule=log HEAD >actual &&\n-\techo -n '' | diff actual -\n+\t! test -s actual\n \"\n \n test_expect_success 'submodule contains untracked and modifed content' \"\n@@ -240,13 +240,13 @@ EOF\n test_expect_success 'submodule contains untracked and modifed content (dirty ignored)' \"\n \techo new > sm1/foo6 &&\n \tgit diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&\n-\techo -n '' | diff actual -\n+\t! test -s actual\n \"\n \n test_expect_success 'submodule contains untracked and modifed content (all ignored)' \"\n \techo new > sm1/foo6 &&\n \tgit diff-index -p --ignore-submodules --submodule=log HEAD >actual &&\n-\techo -n '' | diff actual -\n+\t! test -s actual\n \"\n \n test_expect_success 'submodule contains modifed content' \"\n@@ -295,7 +295,7 @@ EOF\n \n test_expect_success 'modified submodule contains untracked content (all ignored)' \"\n \tgit diff-index -p --ignore-submodules=all --submodule=log HEAD >actual &&\n-\techo -n '' | diff actual -\n+\t! test -s actual\n \"\n \n test_expect_success 'modified submodule contains untracked and modifed content' \"\n@@ -331,7 +331,7 @@ EOF\n test_expect_success 'modified submodule contains untracked and modifed content (all ignored)' \"\n \techo modification >> sm1/foo6 &&\n \tgit diff-index -p --ignore-submodules --submodule=log HEAD >actual &&\n-\techo -n '' | diff actual -\n+\t! test -s actual\n \"\n \n test_expect_success 'modified submodule contains modifed content' \"\n-- \n1.7.1.756.gb48b1\n"}]}