* [PATCH] t4027, t4041: Use printf instead of echo -n
@ 2010-06-24 17:46 Brian Gernhardt
2010-06-24 19:34 ` Johannes Sixt
0 siblings, 1 reply; 5+ messages in thread
From: Brian Gernhardt @ 2010-06-24 17:46 UTC (permalink / raw)
To: Git List; +Cc: Junio C Hamano
BSD's echo doesn't recognize the -n option, so use printf instead
Signed-off-by: Brian Gernhardt <brian@gernhardtsoftware.com>
---
t/t4027-diff-submodule.sh | 10 +++++-----
t/t4041-diff-submodule-option.sh | 14 +++++++-------
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/t/t4027-diff-submodule.sh b/t/t4027-diff-submodule.sh
index 559b41e..ea362d3 100755
--- a/t/t4027-diff-submodule.sh
+++ b/t/t4027-diff-submodule.sh
@@ -105,13 +105,13 @@ test_expect_success 'git diff HEAD with dirty submodule (work tree, refs match)'
expect_from_to >expect.body $subprev $subprev-dirty &&
test_cmp expect.body actual.body &&
git diff --ignore-submodules HEAD >actual2 &&
- echo -n "" | test_cmp - actual2 &&
+ printf "" | test_cmp - actual2 &&
git diff --ignore-submodules=untracked HEAD >actual3 &&
sed -e "1,/^@@/d" actual3 >actual3.body &&
expect_from_to >expect.body $subprev $subprev-dirty &&
test_cmp expect.body actual3.body &&
git diff --ignore-submodules=dirty HEAD >actual4 &&
- echo -n "" | test_cmp - actual4
+ printf "" | test_cmp - actual4
'
test_done
test_expect_success 'git diff HEAD with dirty submodule (index, refs match)' '
@@ -139,11 +139,11 @@ test_expect_success 'git diff HEAD with dirty submodule (untracked, refs match)'
expect_from_to >expect.body $subprev $subprev-dirty &&
test_cmp expect.body actual.body &&
git diff --ignore-submodules=all HEAD >actual2 &&
- echo -n "" | test_cmp - actual2 &&
+ printf "" | test_cmp - actual2 &&
git diff --ignore-submodules=untracked HEAD >actual3 &&
- echo -n "" | test_cmp - actual3 &&
+ printf "" | test_cmp - actual3 &&
git diff --ignore-submodules=dirty HEAD >actual4 &&
- echo -n "" | test_cmp - actual4
+ printf "" | test_cmp - actual4
'
test_expect_success 'git diff (empty submodule dir)' '
diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
index f44b906..7600ed1 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -207,17 +207,17 @@ EOF
test_expect_success 'submodule contains untracked content (untracked ignored)' "
git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&
- echo -n '' | diff actual -
+ printf '' | diff actual -
"
test_expect_success 'submodule contains untracked content (dirty ignored)' "
git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
- echo -n '' | diff actual -
+ printf '' | diff actual -
"
test_expect_success 'submodule contains untracked content (all ignored)' "
git diff-index -p --ignore-submodules=all --submodule=log HEAD >actual &&
- echo -n '' | diff actual -
+ printf '' | diff actual -
"
test_expect_success 'submodule contains untracked and modifed content' "
@@ -240,13 +240,13 @@ EOF
test_expect_success 'submodule contains untracked and modifed content (dirty ignored)' "
echo new > sm1/foo6 &&
git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
- echo -n '' | diff actual -
+ printf '' | diff actual -
"
test_expect_success 'submodule contains untracked and modifed content (all ignored)' "
echo new > sm1/foo6 &&
git diff-index -p --ignore-submodules --submodule=log HEAD >actual &&
- echo -n '' | diff actual -
+ printf '' | diff actual -
"
test_expect_success 'submodule contains modifed content' "
@@ -295,7 +295,7 @@ EOF
test_expect_success 'modified submodule contains untracked content (all ignored)' "
git diff-index -p --ignore-submodules=all --submodule=log HEAD >actual &&
- echo -n '' | diff actual -
+ printf '' | diff actual -
"
test_expect_success 'modified submodule contains untracked and modifed content' "
@@ -331,7 +331,7 @@ EOF
test_expect_success 'modified submodule contains untracked and modifed content (all ignored)' "
echo modification >> sm1/foo6 &&
git diff-index -p --ignore-submodules --submodule=log HEAD >actual &&
- echo -n '' | diff actual -
+ printf '' | diff actual -
"
test_expect_success 'modified submodule contains modifed content' "
--
1.7.1.703.g42c01
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] t4027, t4041: Use printf instead of echo -n
2010-06-24 17:46 [PATCH] t4027, t4041: Use printf instead of echo -n Brian Gernhardt
@ 2010-06-24 19:34 ` Johannes Sixt
2010-06-24 20:10 ` [PATCH v2] t4027,4041: Use test -s to test for an empty file Brian Gernhardt
0 siblings, 1 reply; 5+ messages in thread
From: Johannes Sixt @ 2010-06-24 19:34 UTC (permalink / raw)
To: Brian Gernhardt; +Cc: Git List, Junio C Hamano
On Donnerstag, 24. Juni 2010, Brian Gernhardt wrote:
> BSD's echo doesn't recognize the -n option, so use printf instead
...
> - echo -n "" | test_cmp - actual2 &&
> + printf "" | test_cmp - actual2 &&
Shouldn't you replace these by
! test -s actual2 &&
-- Hannes
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2] t4027,4041: Use test -s to test for an empty file
2010-06-24 19:34 ` Johannes Sixt
@ 2010-06-24 20:10 ` Brian Gernhardt
2010-06-24 20:55 ` Junio C Hamano
2010-06-25 16:26 ` Brandon Casey
0 siblings, 2 replies; 5+ messages in thread
From: Brian Gernhardt @ 2010-06-24 20:10 UTC (permalink / raw)
To: Git List; +Cc: Junio C Hamano
The tests had used a mixture of 'echo -n' (which is non-portable) and
either test_cmp or diff to check if a file is empty. The much easier
and portable method to check for an empty file is '! test -s'
Signed-off-by: Brian Gernhardt <brian@gernhardtsoftware.com>
---
Johannes Sixt wrote:
> Shouldn't you replace these by
>
> ! test -s actual2 &&
Yes, you're right. I was just trying to get the tests to run and didn't really pay attention to what it was trying to do.
t/t4027-diff-submodule.sh | 10 +++++-----
t/t4041-diff-submodule-option.sh | 14 +++++++-------
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/t/t4027-diff-submodule.sh b/t/t4027-diff-submodule.sh
index 559b41e..8f016aa 100755
--- a/t/t4027-diff-submodule.sh
+++ b/t/t4027-diff-submodule.sh
@@ -105,13 +105,13 @@ test_expect_success 'git diff HEAD with dirty submodule (work tree, refs match)'
expect_from_to >expect.body $subprev $subprev-dirty &&
test_cmp expect.body actual.body &&
git diff --ignore-submodules HEAD >actual2 &&
- echo -n "" | test_cmp - actual2 &&
+ ! test -s actual2 &&
git diff --ignore-submodules=untracked HEAD >actual3 &&
sed -e "1,/^@@/d" actual3 >actual3.body &&
expect_from_to >expect.body $subprev $subprev-dirty &&
test_cmp expect.body actual3.body &&
git diff --ignore-submodules=dirty HEAD >actual4 &&
- echo -n "" | test_cmp - actual4
+ ! test -s actual4
'
test_done
test_expect_success 'git diff HEAD with dirty submodule (index, refs match)' '
@@ -139,11 +139,11 @@ test_expect_success 'git diff HEAD with dirty submodule (untracked, refs match)'
expect_from_to >expect.body $subprev $subprev-dirty &&
test_cmp expect.body actual.body &&
git diff --ignore-submodules=all HEAD >actual2 &&
- echo -n "" | test_cmp - actual2 &&
+ ! test -s actual2 &&
git diff --ignore-submodules=untracked HEAD >actual3 &&
- echo -n "" | test_cmp - actual3 &&
+ ! test -s actual3 &&
git diff --ignore-submodules=dirty HEAD >actual4 &&
- echo -n "" | test_cmp - actual4
+ ! test -s actual4
'
test_expect_success 'git diff (empty submodule dir)' '
diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
index f44b906..db9b64d 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -207,17 +207,17 @@ EOF
test_expect_success 'submodule contains untracked content (untracked ignored)' "
git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&
- echo -n '' | diff actual -
+ ! test -s actual -
"
test_expect_success 'submodule contains untracked content (dirty ignored)' "
git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
- echo -n '' | diff actual -
+ ! test -s actual -
"
test_expect_success 'submodule contains untracked content (all ignored)' "
git diff-index -p --ignore-submodules=all --submodule=log HEAD >actual &&
- echo -n '' | diff actual -
+ ! test -s actual -
"
test_expect_success 'submodule contains untracked and modifed content' "
@@ -240,13 +240,13 @@ EOF
test_expect_success 'submodule contains untracked and modifed content (dirty ignored)' "
echo new > sm1/foo6 &&
git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
- echo -n '' | diff actual -
+ ! test -s actual -
"
test_expect_success 'submodule contains untracked and modifed content (all ignored)' "
echo new > sm1/foo6 &&
git diff-index -p --ignore-submodules --submodule=log HEAD >actual &&
- echo -n '' | diff actual -
+ ! test -s actual -
"
test_expect_success 'submodule contains modifed content' "
@@ -295,7 +295,7 @@ EOF
test_expect_success 'modified submodule contains untracked content (all ignored)' "
git diff-index -p --ignore-submodules=all --submodule=log HEAD >actual &&
- echo -n '' | diff actual -
+ ! test -s actual -
"
test_expect_success 'modified submodule contains untracked and modifed content' "
@@ -331,7 +331,7 @@ EOF
test_expect_success 'modified submodule contains untracked and modifed content (all ignored)' "
echo modification >> sm1/foo6 &&
git diff-index -p --ignore-submodules --submodule=log HEAD >actual &&
- echo -n '' | diff actual -
+ ! test -s actual -
"
test_expect_success 'modified submodule contains modifed content' "
--
1.7.1.756.gb48b1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] t4027,4041: Use test -s to test for an empty file
2010-06-24 20:10 ` [PATCH v2] t4027,4041: Use test -s to test for an empty file Brian Gernhardt
@ 2010-06-24 20:55 ` Junio C Hamano
2010-06-25 16:26 ` Brandon Casey
1 sibling, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2010-06-24 20:55 UTC (permalink / raw)
To: Brian Gernhardt; +Cc: Git List, Jens Lehmann, Johannes Sixt
Thanks. Also the leftover "test_done" should be removed and the patch
would be perfect ;-)
Will queue. Thanks, all.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] t4027,4041: Use test -s to test for an empty file
2010-06-24 20:10 ` [PATCH v2] t4027,4041: Use test -s to test for an empty file Brian Gernhardt
2010-06-24 20:55 ` Junio C Hamano
@ 2010-06-25 16:26 ` Brandon Casey
1 sibling, 0 replies; 5+ messages in thread
From: Brandon Casey @ 2010-06-25 16:26 UTC (permalink / raw)
To: Brian Gernhardt; +Cc: Git List, Junio C Hamano
On 06/24/2010 03:10 PM, Brian Gernhardt wrote:
> The tests had used a mixture of 'echo -n' (which is non-portable) and
> either test_cmp or diff to check if a file is empty. The much easier
> and portable method to check for an empty file is '! test -s'
>
> Signed-off-by: Brian Gernhardt <brian@gernhardtsoftware.com>
> ---
>
> Johannes Sixt wrote:
> > Shouldn't you replace these by
> >
> > ! test -s actual2 &&
>
> Yes, you're right. I was just trying to get the tests to run and didn't really pay attention to what it was trying to do.
Ditto. But uh...
> diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
> index f44b906..db9b64d 100755
> --- a/t/t4041-diff-submodule-option.sh
> +++ b/t/t4041-diff-submodule-option.sh
> @@ -207,17 +207,17 @@ EOF
>
> test_expect_success 'submodule contains untracked content (untracked ignored)' "
> git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&
> - echo -n '' | diff actual -
> + ! test -s actual -
^^^
I don't think we need the trailing dash on these.
> "
>
> test_expect_success 'submodule contains untracked content (dirty ignored)' "
> git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
> - echo -n '' | diff actual -
> + ! test -s actual -
> "
>
> test_expect_success 'submodule contains untracked content (all ignored)' "
> git diff-index -p --ignore-submodules=all --submodule=log HEAD >actual &&
> - echo -n '' | diff actual -
> + ! test -s actual -
> "
>
> test_expect_success 'submodule contains untracked and modifed content' "
> @@ -240,13 +240,13 @@ EOF
> test_expect_success 'submodule contains untracked and modifed content (dirty ignored)' "
> echo new > sm1/foo6 &&
> git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
> - echo -n '' | diff actual -
> + ! test -s actual -
> "
>
> test_expect_success 'submodule contains untracked and modifed content (all ignored)' "
> echo new > sm1/foo6 &&
> git diff-index -p --ignore-submodules --submodule=log HEAD >actual &&
> - echo -n '' | diff actual -
> + ! test -s actual -
> "
>
> test_expect_success 'submodule contains modifed content' "
> @@ -295,7 +295,7 @@ EOF
>
> test_expect_success 'modified submodule contains untracked content (all ignored)' "
> git diff-index -p --ignore-submodules=all --submodule=log HEAD >actual &&
> - echo -n '' | diff actual -
> + ! test -s actual -
> "
>
> test_expect_success 'modified submodule contains untracked and modifed content' "
> @@ -331,7 +331,7 @@ EOF
> test_expect_success 'modified submodule contains untracked and modifed content (all ignored)' "
> echo modification >> sm1/foo6 &&
> git diff-index -p --ignore-submodules --submodule=log HEAD >actual &&
> - echo -n '' | diff actual -
> + ! test -s actual -
> "
>
> test_expect_success 'modified submodule contains modifed content' "
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-06-25 16:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-24 17:46 [PATCH] t4027, t4041: Use printf instead of echo -n Brian Gernhardt
2010-06-24 19:34 ` Johannes Sixt
2010-06-24 20:10 ` [PATCH v2] t4027,4041: Use test -s to test for an empty file Brian Gernhardt
2010-06-24 20:55 ` Junio C Hamano
2010-06-25 16:26 ` Brandon Casey
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.