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

Re: [PATCH 15/20] t/t5000-tar-tree.sh: avoid "test <cond> -a/-o <cond>"

From
René Scharfe <l.s.r@web.de>
Date
Jun 10, 2014, 21:47 UTC
Message-ID
<53977D05.5070505@web.de>
In-Reply-To
<20140610200804.GD72977@gmail.com>
Am 10.06.2014 22:08, schrieb David Aguilar:
Show 29 quoted lines
> [Resent using René's correct email address this time, sorry for the noise]
>
> On Fri, Jun 06, 2014 at 07:55:58AM -0700, Elia Pinto wrote:
>> The construct is error-prone; "test" being built-in in most modern
>> shells, the reason to avoid "test <cond> && test <cond>" spawning
>> one extra process by using a single "test <cond> -a <cond>" no
>> longer exists.
>>
>> Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
>> ---
>>   t/t5000-tar-tree.sh |    2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh
>> index 74fc5a8..ad6fa0d 100755
>> --- a/t/t5000-tar-tree.sh
>> +++ b/t/t5000-tar-tree.sh
>> @@ -72,7 +72,7 @@ check_tar() {
>>   			for header in *.paxheader
>>   			do
>>   				data=${header%.paxheader}.data &&
>> -				if test -h $data -o -e $data
>> +				if test -h $data || test -e $data
>>   				then
>
> This looks okay, but it raises a question for the original author
> (René, I think that's you so I've added you to the To: line).
>
> Should that be "test -f" instead of "test -e"?

With -f instead of -e the function would ignore pax path headers for directories and special files. The latter is not relevant for git at all and we don't currently have a test for long directory names, but why restrict the code to handle only regular files?

A better change would be adding tests for symlinks and directories with long names.

Show 6 quoted lines
>
> This is a very minor note and should not block this patch.
> It's probably a change that's better made in a follow-up patch.
>
>>   					path=$(get_pax_header $header path) &&
>>   					if test -n "$path"
Previous: David AguilarNext: Elia Pinto
Message 28 of 35 in “avoid "test <cond> -a/-o <cond>"”
  1. 00/20 avoid "test <cond> -a/-o <cond>"Elia Pinto, Jun 6, 2014
  2. 01/20 check_bindir: avoid "test <cond> -a/-o <cond>"Elia Pinto, Jun 6, 2014
  3. 02/20 contrib/examples/git-clone.sh: avoid "test <cond> -a/-o <cond>"Elia Pinto, Jun 6, 2014
  4. Junio C HamanoJun 9, 2014
  5. 03/20 contrib/examples/git-commit.sh: avoid "test <cond> -a/-o <cond>"Elia Pinto, Jun 6, 2014
  6. David AguilarJun 10, 2014
  7. 04/20 contrib/examples/git-merge.sh: avoid "test <cond> -a/-o <cond>"Elia Pinto, Jun 6, 2014
  8. 05/20 contrib/examples/git-repack.sh: avoid "test <cond> -a/-o <cond>"Elia Pinto, Jun 6, 2014
  9. David AguilarJun 10, 2014
  10. 06/20 contrib/examples/git-resolve.sh: avoid "test <cond> -a/-o <cond>"Elia Pinto, Jun 6, 2014
  11. 07/20 git-bisect.sh: avoid "test <cond> -a/-o <cond>"Elia Pinto, Jun 6, 2014
  12. 08/20 git-mergetool.sh: avoid "test <cond> -a/-o <cond>"Elia Pinto, Jun 6, 2014
  13. David AguilarJun 10, 2014
  14. 09/20 git-rebase--interactive.sh: avoid "test <cond> -a/-o <cond>"Elia Pinto, Jun 6, 2014
  15. David AguilarJun 10, 2014
  16. 10/20 git-submodule.sh: avoid "test <cond> -a/-o <cond>"Elia Pinto, Jun 6, 2014
  17. Junio C HamanoJun 9, 2014
  18. Johannes SixtJun 10, 2014
  19. Johannes SixtJun 10, 2014
  20. 11/20 t/lib-httpd.sh: avoid "test <cond> -a/-o <cond>"Elia Pinto, Jun 6, 2014
  21. 12/20 t/t0025-crlf-auto.sh: avoid "test <cond> -a/-o <cond>"Elia Pinto, Jun 6, 2014
  22. 13/20 t/t0026-eol-config.sh: avoid "test <cond> -a/-o <cond>"Elia Pinto, Jun 6, 2014
  23. 14/20 t/t4102-apply-rename.sh: avoid "test <cond> -a/-o <cond>"Elia Pinto, Jun 6, 2014
  24. 15/20 t/t5000-tar-tree.sh: avoid "test <cond> -a/-o <cond>"Elia Pinto, Jun 6, 2014
  25. David AguilarJun 10, 2014
  26. David AguilarJun 10, 2014
  27. David AguilarJun 10, 2014
  28. René ScharfeJun 10, 2014
  29. 16/20 t/t5403-post-checkout-hook.sh: avoid "test <cond> -a/-o <cond>"Elia Pinto, Jun 6, 2014
  30. 17/20 t/t5538-push-shallow.sh: avoid "test <cond> -a/-o <cond>"Elia Pinto, Jun 6, 2014
  31. 18/20 t/t9814-git-p4-rename.sh: avoid "test <cond> -a/-o <cond>"Elia Pinto, Jun 6, 2014
  32. 19/20 t/test-lib-functions.sh: avoid "test <cond> -a/-o <cond>"Elia Pinto, Jun 6, 2014
  33. 20/20 CodingGuidelines: avoid "test <cond> -a/-o <cond>"Elia Pinto, Jun 6, 2014
  34. Torsten BögershausenJun 6, 2014
  35. Matthieu MoyJun 9, 2014

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.