git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] t4027,4041: Use test -s to test for an empty file

From
BCBrandon Casey <brandon.casey.ctr@nrlssc.navy.mil>
Date
Jun 25, 2010, 16:26 UTC
Message-ID
<kqdYVAmM2c4O6wIC09b253C3JjQEYA9TmnkBdBwGP2ZY3QpzeGjLcA@cipher.nrlssc.navy.mil>
In-Reply-To
<1277410231-12326-1-git-send-email-brian@gernhardtsoftware.com>
On 06/24/2010 03:10 PM, Brian Gernhardt wrote:
Show 13 quoted lines
> 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...
Show 10 quoted lines
> 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.
Show 49 quoted lines
>  "
>  
>  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' "
Previous: Junio C Hamano
Message 5 of 5 in “t4027, t4041: Use printf instead of echo -n”
  1. t4027, t4041: Use printf instead of echo -nBrian Gernhardt, Jun 24, 2010
  2. Johannes SixtJun 24, 2010
  3. t4027,4041: Use test -s to test for an empty fileBrian Gernhardt, Jun 24, 2010
  4. Junio C HamanoJun 24, 2010
  5. Brandon CaseyJun 25, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.