Re: [PATCH 5/6] t1500: avoid setting environment variables outside of tests

2016-05-10 Thread Eric Sunshine
On Tue, May 10, 2016 at 5:11 PM, Junio C Hamano wrote: > SZEDER Gábor writes: >> I wonder if is it really necessary to specify the path to the .git >> directory via $GIT_DIR. Would 'git --git-dir=/over/there' be just as >> good? > > Then you are testing two different things that may go through >

Re: [PATCH 5/6] t1500: avoid setting environment variables outside of tests

2016-05-10 Thread Junio C Hamano
SZEDER Gábor writes: > I wonder if is it really necessary to specify the path to the .git > directory via $GIT_DIR. Would 'git --git-dir=/over/there' be just as > good? Then you are testing two different things that may go through different codepaths. Adding yet another test to check "git --gi

Re: [PATCH 5/6] t1500: avoid setting environment variables outside of tests

2016-05-10 Thread SZEDER Gábor
Quoting Eric Sunshine : On Tue, May 10, 2016 at 3:12 PM, Eric Sunshine wrote: On Tue, May 10, 2016 at 2:39 PM, Jeff King wrote: On Tue, May 10, 2016 at 01:20:54AM -0400, Eric Sunshine wrote: while : do case "$1" in -C) dir="-C $2"; shift; shift ;;

Re: [PATCH 5/6] t1500: avoid setting environment variables outside of tests

2016-05-10 Thread Jeff King
On Tue, May 10, 2016 at 03:59:42PM -0400, Eric Sunshine wrote: > On Tue, May 10, 2016 at 3:48 PM, Eric Sunshine > wrote: > > Actually, I think we can have improved encapsulation and maintain > > readability like this: > > > > case "$1" in > > ... > > -g) env="$2"; shift; shift ;; >

Re: [PATCH 5/6] t1500: avoid setting environment variables outside of tests

2016-05-10 Thread Junio C Hamano
Eric Sunshine writes: > On Tue, May 10, 2016 at 3:12 PM, Eric Sunshine > wrote: >> On Tue, May 10, 2016 at 2:39 PM, Jeff King wrote: >>> On Tue, May 10, 2016 at 01:20:54AM -0400, Eric Sunshine wrote: while : do case "$1" in -C) dir="-

Re: [PATCH 5/6] t1500: avoid setting environment variables outside of tests

2016-05-10 Thread Eric Sunshine
On Tue, May 10, 2016 at 3:48 PM, Eric Sunshine wrote: > Actually, I think we can have improved encapsulation and maintain > readability like this: > > case "$1" in > ... > -g) env="$2"; shift; shift ;; > ... > esac > > ... > test_expect_success "..." ' > if tes

Re: [PATCH 5/6] t1500: avoid setting environment variables outside of tests

2016-05-10 Thread Eric Sunshine
On Tue, May 10, 2016 at 3:12 PM, Eric Sunshine wrote: > On Tue, May 10, 2016 at 2:39 PM, Jeff King wrote: >> On Tue, May 10, 2016 at 01:20:54AM -0400, Eric Sunshine wrote: >>> while : >>> do >>> case "$1" in >>> -C) dir="-C $2"; shift; shift ;; >>>

Re: [PATCH 5/6] t1500: avoid setting environment variables outside of tests

2016-05-10 Thread Junio C Hamano
Eric Sunshine writes: >> I don't know if it's worth worrying about or not. The usual solution is >> something like: >> >> env_git_dir=$2 >> env='GIT_DIR=$env_git_dir; export GIT_DIR' >> ... >> eval "$env" > > Makes sense; I wasn't quite happy with having $2 interpolated > unquoted. Like y

Re: [PATCH 5/6] t1500: avoid setting environment variables outside of tests

2016-05-10 Thread Eric Sunshine
On Tue, May 10, 2016 at 2:39 PM, Jeff King wrote: > On Tue, May 10, 2016 at 01:20:54AM -0400, Eric Sunshine wrote: >> diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh >> @@ -7,11 +7,13 @@ test_description='test git rev-parse' >> while : >> do >> case "$1" in >>

Re: [PATCH 5/6] t1500: avoid setting environment variables outside of tests

2016-05-10 Thread Jeff King
On Tue, May 10, 2016 at 01:20:54AM -0400, Eric Sunshine wrote: > diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh > index c058aa4..525e6d3 100755 > --- a/t/t1500-rev-parse.sh > +++ b/t/t1500-rev-parse.sh > @@ -7,11 +7,13 @@ test_description='test git rev-parse' > test_rev_parse () { >

[PATCH 5/6] t1500: avoid setting environment variables outside of tests

2016-05-09 Thread Eric Sunshine
Ideally, each test should be responsible for setting up state it needs rather than relying upon transient global state. Toward this end, teach test_rev_parse() to accept a "-g " option to allow callers to specify the value of the GIT_DIR environment variable explicitly, and take advantage of this n