All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tests: remove xargs in favor of --stdin where possible
@ 2009-04-23  6:31 Nguyễn Thái Ngọc Duy
  2009-04-23  8:36 ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2009-04-23  6:31 UTC (permalink / raw)
  To: git, Junio C Hamano; +Cc: Nguyễn Thái Ngọc Duy


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 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(-)

diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index f4ca4fc..5c07645 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -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 \
diff --git a/t/t3100-ls-tree-restrict.sh b/t/t3100-ls-tree-restrict.sh
index ee60d03..6e4faf8 100755
--- a/t/t3100-ls-tree-restrict.sh
+++ b/t/t3100-ls-tree-restrict.sh
@@ -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'
 
diff --git a/t/t3101-ls-tree-dirname.sh b/t/t3101-ls-tree-dirname.sh
index 51cb4a3..e0bf312 100755
--- a/t/t3101-ls-tree-dirname.sh
+++ b/t/t3101-ls-tree-dirname.sh
@@ -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'
 
diff --git a/t/t4112-apply-renames.sh b/t/t4112-apply-renames.sh
index f9ad183..6e56fa6 100755
--- a/t/t4112-apply-renames.sh
+++ b/t/t4112-apply-renames.sh
@@ -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'
 
diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh
index abb41b0..f036988 100755
--- a/t/t5000-tar-tree.sh
+++ b/t/t5000-tar-tree.sh
@@ -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" \
-- 
1.6.2.2.693.g5a1be

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] tests: remove xargs in favor of --stdin where possible
  2009-04-23  6:31 [PATCH] tests: remove xargs in favor of --stdin where possible Nguyễn Thái Ngọc Duy
@ 2009-04-23  8:36 ` Junio C Hamano
  2009-04-23  9:22   ` Johannes Sixt
  2009-04-23 10:07   ` Nguyen Thai Ngoc Duy
  0 siblings, 2 replies; 6+ messages in thread
From: Junio C Hamano @ 2009-04-23  8:36 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: git

Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:

> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  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").

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] tests: remove xargs in favor of --stdin where possible
  2009-04-23  8:36 ` Junio C Hamano
@ 2009-04-23  9:22   ` Johannes Sixt
  2009-04-23 10:07   ` Nguyen Thai Ngoc Duy
  1 sibling, 0 replies; 6+ messages in thread
From: Johannes Sixt @ 2009-04-23  9:22 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Nguyễn Thái Ngọc Duy, git

Junio C Hamano schrieb:
> 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).

> (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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] tests: remove xargs in favor of --stdin where possible
  2009-04-23  8:36 ` Junio C Hamano
  2009-04-23  9:22   ` Johannes Sixt
@ 2009-04-23 10:07   ` Nguyen Thai Ngoc Duy
  2009-04-23 10:25     ` Junio C Hamano
  1 sibling, 1 reply; 6+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2009-04-23 10:07 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

2009/4/23 Junio C Hamano <gitster@pobox.com>:
> Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:
>
>> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
>> ---
>>  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?

I worked on busybox win32 port, less commands meant less work for me. So (1).

> 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.
-- 
Duy

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] tests: remove xargs in favor of --stdin where possible
  2009-04-23 10:07   ` Nguyen Thai Ngoc Duy
@ 2009-04-23 10:25     ` Junio C Hamano
  2009-04-23 23:22       ` Nguyen Thai Ngoc Duy
  0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2009-04-23 10:25 UTC (permalink / raw)
  To: Nguyen Thai Ngoc Duy; +Cc: git

Nguyen Thai Ngoc Duy <pclouds@gmail.com> writes:

>> 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?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] tests: remove xargs in favor of --stdin where possible
  2009-04-23 10:25     ` Junio C Hamano
@ 2009-04-23 23:22       ` Nguyen Thai Ngoc Duy
  0 siblings, 0 replies; 6+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2009-04-23 23:22 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Thu, Apr 23, 2009 at 8:25 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Nguyen Thai Ngoc Duy <pclouds@gmail.com> writes:
>
>>> 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?

OK I see. There are some fancy unquoting going on inside. I'd take the
patch back.
-- 
Duy

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-04-23 23:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-23  6:31 [PATCH] tests: remove xargs in favor of --stdin where possible Nguyễn Thái Ngọc Duy
2009-04-23  8:36 ` Junio C Hamano
2009-04-23  9:22   ` Johannes Sixt
2009-04-23 10:07   ` Nguyen Thai Ngoc Duy
2009-04-23 10:25     ` Junio C Hamano
2009-04-23 23:22       ` Nguyen Thai Ngoc Duy

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.