threads / patch / 14648

patcht6030 (bisect): work around Mac OS X "ls"

Subject: [PATCH] t6030 (bisect): work around Mac OS X "ls"

## tl;dr

12 messages between Jul 24, 2008 and Jul 27, 2008. Diffs are folded; open one to read it.

replies: 11people: 4as markdown or json

Jonathan Nieder· Jul 24, 2008, 01:37 UTC · lore

t6030-bisect-porcelain.sh relies on "ls" exiting with nonzero status when asked to list nonexistent files. Unfortunately, /bin/ls on Mac OS X 10.3 exits with exit code 0. So use "echo <shell glob pattern>" and grep instead.

Signed-off-by: Jonathan Nieder <jrnieder@uchicago.edu>
---
	With this change, all the non-git-svn tests pass on my machine.
	I think the fix is portable but I do not have the experience to
	be sure.  So I would be happier if someone looks it over.
 t/t6030-bisect-porcelain.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Show changes to t/t6030-bisect-porcelain.sh +1 −1
diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
index 0626544..d19fc1c 100755
--- a/t/t6030-bisect-porcelain.sh
+++ b/t/t6030-bisect-porcelain.sh
@@ -76,7 +76,7 @@ test_expect_success 'bisect fails if given any junk instead of revs' '
 	test_must_fail git bisect start foo $HASH1 -- &&
 	test_must_fail git bisect start $HASH4 $HASH1 bar -- &&
 	test -z "$(git for-each-ref "refs/bisect/*")" &&
-	test_must_fail ls .git/BISECT_* &&
+	echo .git/BISECT_* | test_must_fail grep BISECT_[^*] &&
 	git bisect start &&
 	test_must_fail git bisect good foo $HASH1 &&
 	test_must_fail git bisect good $HASH1 bar &&
-- 
1.5.6.3.549.g8ca11
Christian Couder· Jul 24, 2008, 05:57 UTC · re: Jonathan Nieder · lore

Re: [PATCH] t6030 (bisect): work around Mac OS X "ls"

Le jeudi 24 juillet 2008, Jonathan Nieder a écrit :
Show 24 quoted lines
> t6030-bisect-porcelain.sh relies on "ls" exiting with nonzero
> status when asked to list nonexistent files.  Unfortunately,
> /bin/ls on Mac OS X 10.3 exits with exit code 0.  So use "echo
> <shell glob pattern>" and grep instead.
>
> Signed-off-by: Jonathan Nieder <jrnieder@uchicago.edu>
> ---
> 	With this change, all the non-git-svn tests pass on my machine.
> 	I think the fix is portable but I do not have the experience to
> 	be sure.  So I would be happier if someone looks it over.
>
>  t/t6030-bisect-porcelain.sh |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
> index 0626544..d19fc1c 100755
> --- a/t/t6030-bisect-porcelain.sh
> +++ b/t/t6030-bisect-porcelain.sh
> @@ -76,7 +76,7 @@ test_expect_success 'bisect fails if given any junk
> instead of revs' ' test_must_fail git bisect start foo $HASH1 -- &&
>  	test_must_fail git bisect start $HASH4 $HASH1 bar -- &&
>  	test -z "$(git for-each-ref "refs/bisect/*")" &&
> -	test_must_fail ls .git/BISECT_* &&
> +	echo .git/BISECT_* | test_must_fail grep BISECT_[^*] &&
Perhaps the following is simpler:
+	test -z "$(ls .git/BISECT_*)" &&
>  	git bisect start &&
>  	test_must_fail git bisect good foo $HASH1 &&
>  	test_must_fail git bisect good $HASH1 bar &&

Thanks, Christian.

Mike Hommey· Jul 24, 2008, 06:06 UTC · re: Christian Couder · lore

Re: [PATCH] t6030 (bisect): work around Mac OS X "ls"

On Thu, Jul 24, 2008 at 07:57:26AM +0200, Christian Couder wrote:
Show 29 quoted lines
> Le jeudi 24 juillet 2008, Jonathan Nieder a écrit :
> > t6030-bisect-porcelain.sh relies on "ls" exiting with nonzero
> > status when asked to list nonexistent files.  Unfortunately,
> > /bin/ls on Mac OS X 10.3 exits with exit code 0.  So use "echo
> > <shell glob pattern>" and grep instead.
> >
> > Signed-off-by: Jonathan Nieder <jrnieder@uchicago.edu>
> > ---
> > 	With this change, all the non-git-svn tests pass on my machine.
> > 	I think the fix is portable but I do not have the experience to
> > 	be sure.  So I would be happier if someone looks it over.
> >
> >  t/t6030-bisect-porcelain.sh |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> >
> > diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
> > index 0626544..d19fc1c 100755
> > --- a/t/t6030-bisect-porcelain.sh
> > +++ b/t/t6030-bisect-porcelain.sh
> > @@ -76,7 +76,7 @@ test_expect_success 'bisect fails if given any junk
> > instead of revs' ' test_must_fail git bisect start foo $HASH1 -- &&
> >  	test_must_fail git bisect start $HASH4 $HASH1 bar -- &&
> >  	test -z "$(git for-each-ref "refs/bisect/*")" &&
> > -	test_must_fail ls .git/BISECT_* &&
> > +	echo .git/BISECT_* | test_must_fail grep BISECT_[^*] &&
> 
> Perhaps the following is simpler:
> 
> +	test -z "$(ls .git/BISECT_*)" &&
That is still a useless use of ls ;)
Mike
Jonathan Nieder· Jul 24, 2008, 07:43 UTC · re: Mike Hommey · lore

[PATCH v2] t6030 (bisect): work around Mac OS X "ls"

t6030-bisect-porcelain.sh relies on "ls" exiting with nonzero status when asked to list nonexistent files. Unfortunately, /bin/ls on Mac OS X 10.3 exits with exit code 0. So look at its output instead.

Signed-off-by: Jonathan Nieder <jrnieder@uchicago.edu>
---
Mike Hommey wrote:
Show 10 quoted lines
> On Thu, Jul 24, 2008 at 07:57:26AM +0200, Christian Couder wrote:
>> Le jeudi 24 juillet 2008, Jonathan Nieder a �crit :
>>> -	test_must_fail ls .git/BISECT_* &&
>>> +	echo .git/BISECT_* | test_must_fail grep BISECT_[^*] &&
>> 
>> Perhaps the following is simpler:
>> 
>> +	test -z "$(ls .git/BISECT_*)" &&
> 
> That is still a useless use of ls ;)
It is much better than what I wrote, at least.
Good night (well, good morning I guess), and thanks.
 t/t6030-bisect-porcelain.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Show changes to t/t6030-bisect-porcelain.sh +1 −1
diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
index 0626544..244fda6 100755
--- a/t/t6030-bisect-porcelain.sh
+++ b/t/t6030-bisect-porcelain.sh
@@ -76,7 +76,7 @@ test_expect_success 'bisect fails if given any junk instead of revs' '
 	test_must_fail git bisect start foo $HASH1 -- &&
 	test_must_fail git bisect start $HASH4 $HASH1 bar -- &&
 	test -z "$(git for-each-ref "refs/bisect/*")" &&
-	test_must_fail ls .git/BISECT_* &&
+	test -z "$(ls .git/BISECT_* 2>/dev/null)" &&
 	git bisect start &&
 	test_must_fail git bisect good foo $HASH1 &&
 	test_must_fail git bisect good $HASH1 bar &&
-- 
1.5.6.3.549.g8ca11
Mike Hommey· Jul 24, 2008, 16:54 UTC · re: Jonathan Nieder · lore

Re: [PATCH v2] t6030 (bisect): work around Mac OS X "ls"

On Thu, Jul 24, 2008 at 02:43:51AM -0500, Jonathan Nieder wrote:
Show 22 quoted lines
> t6030-bisect-porcelain.sh relies on "ls" exiting with nonzero
> status when asked to list nonexistent files.  Unfortunately,
> /bin/ls on Mac OS X 10.3 exits with exit code 0.  So look at
> its output instead.
> 
> Signed-off-by: Jonathan Nieder <jrnieder@uchicago.edu>
> ---
> 
> Mike Hommey wrote:
> 
> > On Thu, Jul 24, 2008 at 07:57:26AM +0200, Christian Couder wrote:
> >> Le jeudi 24 juillet 2008, Jonathan Nieder a �crit :
> >>> -	test_must_fail ls .git/BISECT_* &&
> >>> +	echo .git/BISECT_* | test_must_fail grep BISECT_[^*] &&
> >> 
> >> Perhaps the following is simpler:
> >> 
> >> +	test -z "$(ls .git/BISECT_*)" &&
> > 
> > That is still a useless use of ls ;)
> 
> It is much better than what I wrote, at least.
But could also be written with echo instead of ls.
Mike
Johannes Schindelin· Jul 24, 2008, 17:44 UTC · re: Mike Hommey · lore

Re: [PATCH v2] t6030 (bisect): work around Mac OS X "ls"

Hi,
On Thu, 24 Jul 2008, Mike Hommey wrote:
Show 13 quoted lines
> On Thu, Jul 24, 2008 at 02:43:51AM -0500, Jonathan Nieder wrote:
>
> > Mike Hommey wrote:
> > 
> > > On Thu, Jul 24, 2008 at 07:57:26AM +0200, Christian Couder wrote:
> > >
> > >> +	test -z "$(ls .git/BISECT_*)" &&
> > > 
> > > That is still a useless use of ls ;)
> > 
> > It is much better than what I wrote, at least.
> 
> But could also be written with echo instead of ls.
Sure, but then it looks uglier:
		test ".git/BISECT_*" = "$(echo .git/BISECT_*)" &&
and it is much easier to hide a typo there.

And now the big question: is it performance critical? Or is obvious correctness the highest goal here?

Hth, Dscho

Jonathan Nieder· Jul 24, 2008, 17:51 UTC · re: Mike Hommey · lore

[PATCH v3] t6030 (bisect): work around Mac OS X "ls"

t6030-bisect-porcelain.sh relies on "ls" exiting with nonzero status when asked to list nonexistent files. Unfortunately, /bin/ls on Mac OS X 10.3 exits with exit code 0. So use "echo" instead.

Signed-off-by: Jonathan Nieder <jrnieder@uchicago.edu>
---
 Mike Hommey wrote:
 >>>> +	test -z "$(ls .git/BISECT_*)" &&
 >>> That is still a useless use of ls ;)
 >> It is much better than what I wrote, at least.
 > But could also be written with echo instead of ls.
 How about this?  (The echo is necessary because the argument
 to a case statement does not undergo filename expansion.)
 t/t6030-bisect-porcelain.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Show changes to t/t6030-bisect-porcelain.sh +1 −1
diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
index 0626544..b6841fe 100755
--- a/t/t6030-bisect-porcelain.sh
+++ b/t/t6030-bisect-porcelain.sh
@@ -76,7 +76,7 @@ test_expect_success 'bisect fails if given any junk instead of revs' '
 	test_must_fail git bisect start foo $HASH1 -- &&
 	test_must_fail git bisect start $HASH4 $HASH1 bar -- &&
 	test -z "$(git for-each-ref "refs/bisect/*")" &&
-	test_must_fail ls .git/BISECT_* &&
+	case $(echo .git/BISECT_*) in *\*) ;; *) false ;; esac &&
 	git bisect start &&
 	test_must_fail git bisect good foo $HASH1 &&
 	test_must_fail git bisect good $HASH1 bar &&
-- 
1.5.6.3.549.g8ca11
Jonathan Nieder· Jul 24, 2008, 18:16 UTC · re: Jonathan Nieder · lore

Re: [PATCH v3] t6030 (bisect): work around Mac OS X "ls"

Jonathan Nieder wrote:
> -	test_must_fail ls .git/BISECT_* &&
> +	case $(echo .git/BISECT_*) in *\*) ;; *) false ;; esac &&

Actually, if we want to go that route, I prefer the version Dscho gave. So please ignore my patch v3; I'd rather people choose between Christian's and Dscho's suggestions.

Personally, without knowing how much time avoiding the ls saves, I
am not sure which is best.  Certainly the version with "ls" is clearer,
which is most important; but if the time savings (of avoiding such
constructs generally) are significant, then that is very much worthwhile
- a faster test suite can be run more often.
Jonathan
Christian Couder· Jul 27, 2008, 03:19 UTC · re: Jonathan Nieder · lore

Re: [PATCH v2] t6030 (bisect): work around Mac OS X "ls"

Le jeudi 24 juillet 2008, Jonathan Nieder a écrit :
Show 6 quoted lines
> t6030-bisect-porcelain.sh relies on "ls" exiting with nonzero
> status when asked to list nonexistent files.  Unfortunately,
> /bin/ls on Mac OS X 10.3 exits with exit code 0.  So look at
> its output instead.
>
> Signed-off-by: Jonathan Nieder <jrnieder@uchicago.edu>
Acked-by: Christian Couder <chriscool@tuxfamily.org>

Thanks, Christian.

Show 34 quoted lines
> ---
>
> Mike Hommey wrote:
> > On Thu, Jul 24, 2008 at 07:57:26AM +0200, Christian Couder wrote:
> >> Le jeudi 24 juillet 2008, Jonathan Nieder a écrit :
> >>> -	test_must_fail ls .git/BISECT_* &&
> >>> +	echo .git/BISECT_* | test_must_fail grep BISECT_[^*] &&
> >>
> >> Perhaps the following is simpler:
> >>
> >> +	test -z "$(ls .git/BISECT_*)" &&
> >
> > That is still a useless use of ls ;)
>
> It is much better than what I wrote, at least.
>
> Good night (well, good morning I guess), and thanks.
>
>  t/t6030-bisect-porcelain.sh |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
> index 0626544..244fda6 100755
> --- a/t/t6030-bisect-porcelain.sh
> +++ b/t/t6030-bisect-porcelain.sh
> @@ -76,7 +76,7 @@ test_expect_success 'bisect fails if given any junk
> instead of revs' ' test_must_fail git bisect start foo $HASH1 -- &&
>  	test_must_fail git bisect start $HASH4 $HASH1 bar -- &&
>  	test -z "$(git for-each-ref "refs/bisect/*")" &&
> -	test_must_fail ls .git/BISECT_* &&
> +	test -z "$(ls .git/BISECT_* 2>/dev/null)" &&
>  	git bisect start &&
>  	test_must_fail git bisect good foo $HASH1 &&
>  	test_must_fail git bisect good $HASH1 bar &&
Christian Couder· Jul 27, 2008, 04:04 UTC · re: Christian Couder · lore

Re: [PATCH v2] t6030 (bisect): work around Mac OS X "ls"

Le dimanche 27 juillet 2008, Christian Couder a écrit :
Show 9 quoted lines
> Le jeudi 24 juillet 2008, Jonathan Nieder a écrit :
> > t6030-bisect-porcelain.sh relies on "ls" exiting with nonzero
> > status when asked to list nonexistent files.  Unfortunately,
> > /bin/ls on Mac OS X 10.3 exits with exit code 0.  So look at
> > its output instead.
> >
> > Signed-off-by: Jonathan Nieder <jrnieder@uchicago.edu>
>
> Acked-by: Christian Couder <chriscool@tuxfamily.org>

It seems that there is a problem with the message itself though. When I "git am" it, I get:

fatal: cannot convert from x-unknown to utf-8

It seems that it is mime encoded or something and my git (1.6.0.rc0.80.gf54f0) doesn't like it.

Regards, Christian.

Jonathan Nieder· Jul 27, 2008, 04:53 UTC · re: Christian Couder · lore

[PATCH v2] t6030 (bisect): work around Mac OS X "ls"

t6030-bisect-porcelain.sh relies on "ls" exiting with nonzero status when asked to list nonexistent files. Unfortunately, /bin/ls on Mac OS X 10.3 exits with exit code 0. So look at its output instead.

Signed-off-by: Jonathan Nieder <jrnieder@uchicago.edu>
Acked-by: Christian Couder <chriscool@tuxfamily.org>
---
On Sun, 27 Jul 2008, Christian Couder wrote:
> It seems that there is a problem with the message itself though. When I "git 
> am" it, I get:
> 
> fatal: cannot convert from x-unknown to utf-8
Hmm, not sure what happened.  Maybe resending it will work...
 t/t6030-bisect-porcelain.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Show changes to t/t6030-bisect-porcelain.sh +1 −1
diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
index 0626544..244fda6 100755
--- a/t/t6030-bisect-porcelain.sh
+++ b/t/t6030-bisect-porcelain.sh
@@ -76,7 +76,7 @@ test_expect_success 'bisect fails if given any junk instead of revs' '
 	test_must_fail git bisect start foo $HASH1 -- &&
 	test_must_fail git bisect start $HASH4 $HASH1 bar -- &&
 	test -z "$(git for-each-ref "refs/bisect/*")" &&
-	test_must_fail ls .git/BISECT_* &&
+	test -z "$(ls .git/BISECT_* 2>/dev/null)" &&
 	git bisect start &&
 	test_must_fail git bisect good foo $HASH1 &&
 	test_must_fail git bisect good $HASH1 bar &&
-- 
1.5.5.1.328.gbfcc6
Christian Couder· Jul 27, 2008, 05:10 UTC · re: Jonathan Nieder · lore

Re: [PATCH v2] t6030 (bisect): work around Mac OS X "ls"

Le dimanche 27 juillet 2008, Jonathan Nieder a écrit :
Show 16 quoted lines
> t6030-bisect-porcelain.sh relies on "ls" exiting with nonzero
> status when asked to list nonexistent files.  Unfortunately,
> /bin/ls on Mac OS X 10.3 exits with exit code 0.  So look at
> its output instead.
>
> Signed-off-by: Jonathan Nieder <jrnieder@uchicago.edu>
> Acked-by: Christian Couder <chriscool@tuxfamily.org>
> ---
>
> On Sun, 27 Jul 2008, Christian Couder wrote:
> > It seems that there is a problem with the message itself though. When I
> > "git am" it, I get:
> >
> > fatal: cannot convert from x-unknown to utf-8
>
> Hmm, not sure what happened.  Maybe resending it will work...
Yes, this one works fine.

Thanks, Christian.

Show 17 quoted lines
>
>  t/t6030-bisect-porcelain.sh |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
> index 0626544..244fda6 100755
> --- a/t/t6030-bisect-porcelain.sh
> +++ b/t/t6030-bisect-porcelain.sh
> @@ -76,7 +76,7 @@ test_expect_success 'bisect fails if given any junk
> instead of revs' ' test_must_fail git bisect start foo $HASH1 -- &&
>  	test_must_fail git bisect start $HASH4 $HASH1 bar -- &&
>  	test -z "$(git for-each-ref "refs/bisect/*")" &&
> -	test_must_fail ls .git/BISECT_* &&
> +	test -z "$(ls .git/BISECT_* 2>/dev/null)" &&
>  	git bisect start &&
>  	test_must_fail git bisect good foo $HASH1 &&
>  	test_must_fail git bisect good $HASH1 bar &&

← back to recent threads