tests: remove xargs in favor of --stdin where possible
PATCH 1/1 tests: remove xargs in favor of --stdin where possible
---
Patch "Convert to use quiet option when available" reminds me I had a similar patch to remove (mostly) xargs usage from tests.
t/t0000-basic.sh | 2 +- t/t3100-ls-tree-restrict.sh | 2 +- t/t3101-ls-tree-dirname.sh | 2 +- t/t4112-apply-renames.sh | 2 +- t/t5000-tar-tree.sh | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-)
t/t0000-basic.sh +1 -1
@@ -142,7 +142,7 @@ fi test_expect_success \ 'adding various types of objects with git update-index --add.' \ - 'find path* ! -type d -print | xargs git update-index --add' + 'find path* ! -type d -print | git update-index --add --stdin' # Show them and see that matches what we expect. test_expect_success \
t/t3100-ls-tree-restrict.sh +1 -1
@@ -39,7 +39,7 @@ test_expect_success \ echo Lo >path2/foo && echo Mi >path2/baz/b && find path? \( -type f -o -type l \) -print | - xargs git update-index --add && + git update-index --add --stdin && tree=`git write-tree` && echo $tree'
t/t3101-ls-tree-dirname.sh +1 -1
@@ -35,7 +35,7 @@ test_expect_success \ echo 111 >path3/1.txt && echo 222 >path3/2.txt && find *.txt path* \( -type f -o -type l \) -print | - xargs git update-index --add && + git update-index --add --stdin && tree=`git write-tree` && echo $tree'
t/t4112-apply-renames.sh +1 -1
@@ -135,7 +135,7 @@ copy to klibc/arch/README +add a few lines at the end of it. EOF -find klibc -type f -print | xargs git update-index --add -- +find klibc -type f -print | git update-index --add --stdin test_expect_success 'check rename/copy patch' 'git apply --check patch'
t/t5000-tar-tree.sh +2 -2
@@ -54,8 +54,8 @@ test_expect_success \ test_expect_success \ 'add files to repository' \ - 'find a -type f | xargs git update-index --add && - find a -type l | xargs git update-index --add && + 'find a -type f | git update-index --add --stdin && + find a -type l | git update-index --add --stdin && treeid=`git write-tree` && echo $treeid >treeid && git update-ref HEAD $(TZ=GMT GIT_COMMITTER_DATE="2005-05-27 22:00:00" \
Signature · 1 line
1.6.2.2.693.g5a1be
Quoted 4 lines · Nguyễn Thái Ngọc Duy
Signed-off-by Nguyễn Thái Ngọc Duy <[email protected]>---
Patch "Convert to use quiet option when available" reminds me I had a similar patch to remove (mostly) xargs usage from tests.
The reason being...?
(1) xargs is not universally available, or portable enough?
(2) people may learn from tests, and we should demostrate our ability?
(3) something else?
If the reason is (1) I would understand it, but if it is (2) then I am a bit reluctant.
The tests may not break with your change because none of them may use problematic characters (especially "\n" and '"'), but update-index --stdin without -z is not suitable for reading from output from "find" without -0 option (on the other hand, "update-index -z --stdin" is good for reading output from "find -0"; but for portability we avoid GNUism "find -0").
Quoted 4 lines · Junio C Hamano
The tests may not break with your change because none of them may use problematic characters (especially "\n" and '"'), but update-index --stdin without -z is not suitable for reading from output from "find" without -0 option
Why should this be so? I thought I need -0/-z only if there are "\n" in file names (and I specifially talk about a find | update-index pipeline).
Quoted 2 lines
(on the other hand, "update-index -z --stdin" is good for reading output from "find -0"; but for portability we avoid GNUism "find -0").
Sure, -0/-z is safer and to be used in scripts. But for an ad-hoc command that I type on the command line, why should I use -0/-z if I know that I don't have any "\n" in my file names?
-- Hannes
2009/4/23 Junio C Hamano <[email protected]>:
Quoted 7 lines
Quoted 4 lines · Nguyễn Thái Ngọc Duy
Signed-off-by Nguyễn Thái Ngọc Duy <[email protected]>---
Patch "Convert to use quiet option when available" reminds me I had a similar patch to remove (mostly) xargs usage from tests.
Quoted 7 lines
The reason being...?
(1) xargs is not universally available, or portable enough?
(2) people may learn from tests, and we should demostrate our ability?
(3) something else?
I worked on busybox win32 port, less commands meant less work for me. So (1).
Quoted 5 lines
The tests may not break with your change because none of them may use problematic characters (especially "\n" and '"'), but update-index --stdin without -z is not suitable for reading from output from "find" without -0 option (on the other hand, "update-index -z --stdin" is good for reading output from "find -0"; but for portability we avoid GNUism "find -0").
It can't be as safe as find -0| update-index -z, but it would be equivalent to find|xargs, isn't it? Both separate arguments by \n.
Signature · 1 line
Duy
Quoted 8 lines · Nguyen Thai Ngoc Duy
Quoted 5 lines
The tests may not break with your change because none of them may use problematic characters (especially "\n" and '"'), but update-index --stdin without -z is not suitable for reading from output from "find" without -0 option (on the other hand, "update-index -z --stdin" is good for reading output from "find -0"; but for portability we avoid GNUism "find -0").
It can't be as safe as find -0| update-index -z, but it would be equivalent to find|xargs, isn't it? Both separate arguments by \n.
Have you worked with pathnames with high-bit set and without core.quotepath set to false?
Quoted 8 lines · Junio C Hamano
Quoted 6 lines · Nguyen Thai Ngoc Duy
Quoted 5 lines
The tests may not break with your change because none of them may use problematic characters (especially "\n" and '"'), but update-index --stdin without -z is not suitable for reading from output from "find" without -0 option (on the other hand, "update-index -z --stdin" is good for reading output from "find -0"; but for portability we avoid GNUism "find -0").
Quoted 5 lines
Quoted 2 lines
It can't be as safe as find -0| update-index -z, but it would be equivalent to find|xargs, isn't it? Both separate arguments by \n.
Have you worked with pathnames with high-bit set and without core.quotepath set to false?
OK I see. There are some fancy unquoting going on inside. I'd take the patch back.
Signature · 1 line
Duy