{"thread":{"id":"19017","subject":"[PATCH] tests: remove xargs in favor of --stdin where possible","startedAt":"2009-04-23T06:31:21Z","lastAt":"2009-04-23T23:22:10Z","messageCount":6,"participants":["Nguyễn Thái Ngọc Duy","Junio C Hamano","Johannes Sixt","Nguyen Thai Ngoc Duy"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"112051","messageId":"1240468281-23815-1-git-send-email-pclouds@gmail.com","threadId":"19017","inReplyTo":null,"subject":"[PATCH] tests: remove xargs in favor of --stdin where possible","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2009-04-23T06:31:21Z","receivedAt":"2009-04-23T06:31:21Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n Patch \"Convert to use quiet option when available\" reminds me I had a similar\n patch to remove (mostly) xargs usage from tests.\n\n t/t0000-basic.sh            |    2 +-\n t/t3100-ls-tree-restrict.sh |    2 +-\n t/t3101-ls-tree-dirname.sh  |    2 +-\n t/t4112-apply-renames.sh    |    2 +-\n t/t5000-tar-tree.sh         |    4 ++--\n 5 files changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/t/t0000-basic.sh b/t/t0000-basic.sh\nindex f4ca4fc..5c07645 100755\n--- a/t/t0000-basic.sh\n+++ b/t/t0000-basic.sh\n@@ -142,7 +142,7 @@ fi\n \n test_expect_success \\\n     'adding various types of objects with git update-index --add.' \\\n-    'find path* ! -type d -print | xargs git update-index --add'\n+    'find path* ! -type d -print | git update-index --add --stdin'\n \n # Show them and see that matches what we expect.\n test_expect_success \\\ndiff --git a/t/t3100-ls-tree-restrict.sh b/t/t3100-ls-tree-restrict.sh\nindex ee60d03..6e4faf8 100755\n--- a/t/t3100-ls-tree-restrict.sh\n+++ b/t/t3100-ls-tree-restrict.sh\n@@ -39,7 +39,7 @@ test_expect_success \\\n      echo Lo >path2/foo &&\n      echo Mi >path2/baz/b &&\n      find path? \\( -type f -o -type l \\) -print |\n-     xargs git update-index --add &&\n+     git update-index --add --stdin &&\n      tree=`git write-tree` &&\n      echo $tree'\n \ndiff --git a/t/t3101-ls-tree-dirname.sh b/t/t3101-ls-tree-dirname.sh\nindex 51cb4a3..e0bf312 100755\n--- a/t/t3101-ls-tree-dirname.sh\n+++ b/t/t3101-ls-tree-dirname.sh\n@@ -35,7 +35,7 @@ test_expect_success \\\n      echo 111 >path3/1.txt &&\n      echo 222 >path3/2.txt &&\n      find *.txt path* \\( -type f -o -type l \\) -print |\n-     xargs git update-index --add &&\n+     git update-index --add --stdin &&\n      tree=`git write-tree` &&\n      echo $tree'\n \ndiff --git a/t/t4112-apply-renames.sh b/t/t4112-apply-renames.sh\nindex f9ad183..6e56fa6 100755\n--- a/t/t4112-apply-renames.sh\n+++ b/t/t4112-apply-renames.sh\n@@ -135,7 +135,7 @@ copy to klibc/arch/README\n +add a few lines at the end of it.\n EOF\n \n-find klibc -type f -print | xargs git update-index --add --\n+find klibc -type f -print | git update-index --add --stdin\n \n test_expect_success 'check rename/copy patch' 'git apply --check patch'\n \ndiff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh\nindex abb41b0..f036988 100755\n--- a/t/t5000-tar-tree.sh\n+++ b/t/t5000-tar-tree.sh\n@@ -54,8 +54,8 @@ test_expect_success \\\n \n test_expect_success \\\n     'add files to repository' \\\n-    'find a -type f | xargs git update-index --add &&\n-     find a -type l | xargs git update-index --add &&\n+    'find a -type f | git update-index --add --stdin &&\n+     find a -type l | git update-index --add --stdin &&\n      treeid=`git write-tree` &&\n      echo $treeid >treeid &&\n      git update-ref HEAD $(TZ=GMT GIT_COMMITTER_DATE=\"2005-05-27 22:00:00\" \\\n-- \n1.6.2.2.693.g5a1be\n"},{"id":"112059","messageId":"7vfxfzwytx.fsf@gitster.siamese.dyndns.org","threadId":"19017","inReplyTo":"1240468281-23815-1-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH] tests: remove xargs in favor of --stdin where possible","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-04-23T08:36:58Z","receivedAt":"2009-04-23T08:36:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n\n> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n> ---\n>  Patch \"Convert to use quiet option when available\" reminds me I had a similar\n>  patch to remove (mostly) xargs usage from tests.\n\nThe reason being...?\n\n (1) xargs is not universally available, or portable enough?\n\n (2) people may learn from tests, and we should demostrate our ability?\n\n (3) something else?\n\nIf the reason is (1) I would understand it, but if it is (2) then I am a\nbit reluctant.  \n\nThe tests may not break with your change because none of them may use\nproblematic characters (especially \"\\n\" and '\"'), but update-index --stdin\nwithout -z is not suitable for reading from output from \"find\" without -0\noption (on the other hand, \"update-index -z --stdin\" is good for reading\noutput from \"find -0\"; but for portability we avoid GNUism \"find -0\").\n"},{"id":"112062","messageId":"49F0334C.6000004@viscovery.net","threadId":"19017","inReplyTo":"7vfxfzwytx.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] tests: remove xargs in favor of --stdin where possible","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2009-04-23T09:22:20Z","receivedAt":"2009-04-23T09:22:20Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Junio C Hamano schrieb:\n> The tests may not break with your change because none of them may use\n> problematic characters (especially \"\\n\" and '\"'), but update-index --stdin\n> without -z is not suitable for reading from output from \"find\" without -0\n> option\n\nWhy should this be so? I thought I need -0/-z only if there are \"\\n\" in\nfile names (and I specifially talk about a find | update-index pipeline).\n\n> (on the other hand, \"update-index -z --stdin\" is good for reading\n> output from \"find -0\"; but for portability we avoid GNUism \"find -0\").\n\nSure, -0/-z is safer and to be used in scripts. But for an ad-hoc command\nthat I type on the command line, why should I use -0/-z if I know that I\ndon't have any \"\\n\" in my file names?\n\n-- Hannes\n"},{"id":"112075","messageId":"fcaeb9bf0904230307h2d4ee691y412e9cf31e4e90c3@mail.gmail.com","threadId":"19017","inReplyTo":"7vfxfzwytx.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] tests: remove xargs in favor of --stdin where possible","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2009-04-23T10:07:19Z","receivedAt":"2009-04-23T10:07:19Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"2009/4/23 Junio C Hamano <gitster@pobox.com>:\n> Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n>\n>> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n>> ---\n>>  Patch \"Convert to use quiet option when available\" reminds me I had a similar\n>>  patch to remove (mostly) xargs usage from tests.\n>\n> The reason being...?\n>\n>  (1) xargs is not universally available, or portable enough?\n>\n>  (2) people may learn from tests, and we should demostrate our ability?\n>\n>  (3) something else?\n\nI worked on busybox win32 port, less commands meant less work for me. So (1).\n\n> The tests may not break with your change because none of them may use\n> problematic characters (especially \"\\n\" and '\"'), but update-index --stdin\n> without -z is not suitable for reading from output from \"find\" without -0\n> option (on the other hand, \"update-index -z --stdin\" is good for reading\n> output from \"find -0\"; but for portability we avoid GNUism \"find -0\").\n\nIt can't be as safe as find -0| update-index -z, but it would be\nequivalent to find|xargs, isn't it? Both separate arguments by \\n.\n-- \nDuy\n"},{"id":"112076","messageId":"7v8wlrwtt3.fsf@gitster.siamese.dyndns.org","threadId":"19017","inReplyTo":"fcaeb9bf0904230307h2d4ee691y412e9cf31e4e90c3@mail.gmail.com","subject":"Re: [PATCH] tests: remove xargs in favor of --stdin where possible","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-04-23T10:25:28Z","receivedAt":"2009-04-23T10:25:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyen Thai Ngoc Duy <pclouds@gmail.com> writes:\n\n>> The tests may not break with your change because none of them may use\n>> problematic characters (especially \"\\n\" and '\"'), but update-index --stdin\n>> without -z is not suitable for reading from output from \"find\" without -0\n>> option (on the other hand, \"update-index -z --stdin\" is good for reading\n>> output from \"find -0\"; but for portability we avoid GNUism \"find -0\").\n>\n> It can't be as safe as find -0| update-index -z, but it would be\n> equivalent to find|xargs, isn't it? Both separate arguments by \\n.\n\nHave you worked with pathnames with high-bit set and without\ncore.quotepath set to false?\n"},{"id":"112145","messageId":"fcaeb9bf0904231622x721483f2v9f009784509676b@mail.gmail.com","threadId":"19017","inReplyTo":"7v8wlrwtt3.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] tests: remove xargs in favor of --stdin where possible","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2009-04-23T23:22:10Z","receivedAt":"2009-04-23T23:22:10Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Thu, Apr 23, 2009 at 8:25 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Nguyen Thai Ngoc Duy <pclouds@gmail.com> writes:\n>\n>>> The tests may not break with your change because none of them may use\n>>> problematic characters (especially \"\\n\" and '\"'), but update-index --stdin\n>>> without -z is not suitable for reading from output from \"find\" without -0\n>>> option (on the other hand, \"update-index -z --stdin\" is good for reading\n>>> output from \"find -0\"; but for portability we avoid GNUism \"find -0\").\n>>\n>> It can't be as safe as find -0| update-index -z, but it would be\n>> equivalent to find|xargs, isn't it? Both separate arguments by \\n.\n>\n> Have you worked with pathnames with high-bit set and without\n> core.quotepath set to false?\n\nOK I see. There are some fancy unquoting going on inside. I'd take the\npatch back.\n-- \nDuy\n"}]}