* [PATCH] HOME must be set before calling git-init when creating test repositories @ 2011-03-25 20:05 Alex Riesen 2011-03-25 20:44 ` [PATCH, fixed] " Alex Riesen 2011-03-25 20:49 ` [PATCH] " Junio C Hamano 0 siblings, 2 replies; 14+ messages in thread From: Alex Riesen @ 2011-03-25 20:05 UTC (permalink / raw) To: git; +Cc: Junio C Hamano Otherwise the created test repositories will be affected by users ~/.gitconfig. For example, setting core.logAllrefupdates in users config will make all calls to "git config --unset core.logAllrefupdates" fail which will break the first test which uses the statement and expects it to succeed. Signed-off-by: Alex Riesen <raa.lkml@gmail.com> --- The first test which fails is t2017, btw. I still wonder if this should be moved even further up. t/test-lib.sh | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/t/test-lib.sh b/t/test-lib.sh index 7cc9a52..4f394c3 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -984,14 +984,14 @@ rm -fr "$test" || { exit 1 } +HOME=$(pwd) +export HOME + test_create_repo "$test" # Use -P to resolve symlinks in our working directory so that the cwd # in subprocesses like git equals our $PWD (for pathname comparisons). cd -P "$test" || exit 1 -HOME=$(pwd) -export HOME - this_test=${0##*/} this_test=${this_test%%-*} for skp in $GIT_SKIP_TESTS -- 1.7.4.1.271.g4540f ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH, fixed] HOME must be set before calling git-init when creating test repositories 2011-03-25 20:05 [PATCH] HOME must be set before calling git-init when creating test repositories Alex Riesen @ 2011-03-25 20:44 ` Alex Riesen 2011-03-25 20:49 ` [PATCH] " Junio C Hamano 1 sibling, 0 replies; 14+ messages in thread From: Alex Riesen @ 2011-03-25 20:44 UTC (permalink / raw) To: git; +Cc: Junio C Hamano Otherwise the created test repositories will be affected by users ~/.gitconfig. For example, setting core.logAllrefupdates in users config will make all calls to "git config --unset core.logAllrefupdates" fail which will break the first test which uses the statement and expects it to succeed. Signed-off-by: Alex Riesen <raa.lkml@gmail.com> --- Aah... Sorry. Missed the test's part of the new HOME. t/test-lib.sh | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/t/test-lib.sh b/t/test-lib.sh index 7cc9a52..8792e4a 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -984,14 +984,14 @@ rm -fr "$test" || { exit 1 } +HOME=$(pwd)/"$test" +export HOME + test_create_repo "$test" # Use -P to resolve symlinks in our working directory so that the cwd # in subprocesses like git equals our $PWD (for pathname comparisons). cd -P "$test" || exit 1 -HOME=$(pwd) -export HOME - this_test=${0##*/} this_test=${this_test%%-*} for skp in $GIT_SKIP_TESTS -- 1.7.4.1.271.g4540f ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH] HOME must be set before calling git-init when creating test repositories 2011-03-25 20:05 [PATCH] HOME must be set before calling git-init when creating test repositories Alex Riesen 2011-03-25 20:44 ` [PATCH, fixed] " Alex Riesen @ 2011-03-25 20:49 ` Junio C Hamano 2011-03-25 21:01 ` Alex Riesen 1 sibling, 1 reply; 14+ messages in thread From: Junio C Hamano @ 2011-03-25 20:49 UTC (permalink / raw) To: Alex Riesen; +Cc: git Alex Riesen <raa.lkml@gmail.com> writes: > Otherwise the created test repositories will be affected by users ~/.gitconfig. > For example, setting core.logAllrefupdates in users config will make all > calls to "git config --unset core.logAllrefupdates" fail which will break > the first test which uses the statement and expects it to succeed. Doesn't this change the location of HOME used during the test as well? ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] HOME must be set before calling git-init when creating test repositories 2011-03-25 20:49 ` [PATCH] " Junio C Hamano @ 2011-03-25 21:01 ` Alex Riesen 2011-03-25 21:30 ` Junio C Hamano 0 siblings, 1 reply; 14+ messages in thread From: Alex Riesen @ 2011-03-25 21:01 UTC (permalink / raw) To: Junio C Hamano; +Cc: git On Fri, Mar 25, 2011 at 21:49, Junio C Hamano <gitster@pobox.com> wrote: > Alex Riesen <raa.lkml@gmail.com> writes: > >> Otherwise the created test repositories will be affected by users ~/.gitconfig. >> For example, setting core.logAllrefupdates in users config will make all >> calls to "git config --unset core.logAllrefupdates" fail which will break >> the first test which uses the statement and expects it to succeed. > > Doesn't this change the location of HOME used during the test as well? > As long as the test only includes test-lib.sh only once - it doesn't. Why? Or rather, how? ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] HOME must be set before calling git-init when creating test repositories 2011-03-25 21:01 ` Alex Riesen @ 2011-03-25 21:30 ` Junio C Hamano 2011-03-25 21:51 ` Alex Riesen 0 siblings, 1 reply; 14+ messages in thread From: Junio C Hamano @ 2011-03-25 21:30 UTC (permalink / raw) To: Alex Riesen; +Cc: Junio C Hamano, git Alex Riesen <raa.lkml@gmail.com> writes: > On Fri, Mar 25, 2011 at 21:49, Junio C Hamano <gitster@pobox.com> wrote: > >> Doesn't this change the location of HOME used during the test as well? > > As long as the test only includes test-lib.sh only once - it doesn't. > Why? Or rather, how? I thought you moved HOME=$(pwd) across "cd somewhere-else". Doesn't it change what is returned from pwd? ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] HOME must be set before calling git-init when creating test repositories 2011-03-25 21:30 ` Junio C Hamano @ 2011-03-25 21:51 ` Alex Riesen 2011-03-25 22:39 ` Junio C Hamano 0 siblings, 1 reply; 14+ messages in thread From: Alex Riesen @ 2011-03-25 21:51 UTC (permalink / raw) To: Junio C Hamano; +Cc: git On Fri, Mar 25, 2011 at 22:30, Junio C Hamano <gitster@pobox.com> wrote: > Alex Riesen <raa.lkml@gmail.com> writes: > >> On Fri, Mar 25, 2011 at 21:49, Junio C Hamano <gitster@pobox.com> wrote: >> >>> Doesn't this change the location of HOME used during the test as well? >> >> As long as the test only includes test-lib.sh only once - it doesn't. >> Why? Or rather, how? > > I thought you moved HOME=$(pwd) across "cd somewhere-else". Doesn't it > change what is returned from pwd? > Oh, it does. That's why the second patch (prefixed "[PATCH, fixed]"). It makes HOME to be "$(pwd)/somewhere-else", or precisely: HOME="$(pwd)"/"$test" export HOME ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] HOME must be set before calling git-init when creating test repositories 2011-03-25 21:51 ` Alex Riesen @ 2011-03-25 22:39 ` Junio C Hamano 2011-03-26 10:08 ` Alex Riesen 0 siblings, 1 reply; 14+ messages in thread From: Junio C Hamano @ 2011-03-25 22:39 UTC (permalink / raw) To: Alex Riesen; +Cc: git Alex Riesen <raa.lkml@gmail.com> writes: > On Fri, Mar 25, 2011 at 22:30, Junio C Hamano <gitster@pobox.com> wrote: >> Alex Riesen <raa.lkml@gmail.com> writes: >> >>> On Fri, Mar 25, 2011 at 21:49, Junio C Hamano <gitster@pobox.com> wrote: >>> >>>> Doesn't this change the location of HOME used during the test as well? >>> >>> As long as the test only includes test-lib.sh only once - it doesn't. >>> Why? Or rather, how? >> >> I thought you moved HOME=$(pwd) across "cd somewhere-else". Doesn't it >> change what is returned from pwd? >> > > Oh, it does. That's why the second patch (prefixed "[PATCH, fixed]"). > It makes HOME to be "$(pwd)/somewhere-else", or precisely: > > HOME="$(pwd)"/"$test" > export HOME What happens to people who has non-empty "$root", iow, their $test begins with '/'? I am not saying that having HOME at t/ directory instead of t/trash-*/ directory would necessarily break things (I don't know). I am just pointing out that the patch changes behaviour. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] HOME must be set before calling git-init when creating test repositories 2011-03-25 22:39 ` Junio C Hamano @ 2011-03-26 10:08 ` Alex Riesen 2011-03-26 14:11 ` Jeff King 0 siblings, 1 reply; 14+ messages in thread From: Alex Riesen @ 2011-03-26 10:08 UTC (permalink / raw) To: Junio C Hamano; +Cc: git On Fri, Mar 25, 2011 at 23:39, Junio C Hamano <gitster@pobox.com> wrote: > Alex Riesen <raa.lkml@gmail.com> writes: > >> On Fri, Mar 25, 2011 at 22:30, Junio C Hamano <gitster@pobox.com> wrote: >>> Alex Riesen <raa.lkml@gmail.com> writes: >>> >>>> On Fri, Mar 25, 2011 at 21:49, Junio C Hamano <gitster@pobox.com> wrote: >>>> >>>>> Doesn't this change the location of HOME used during the test as well? >>>> >>>> As long as the test only includes test-lib.sh only once - it doesn't. >>>> Why? Or rather, how? >>> >>> I thought you moved HOME=$(pwd) across "cd somewhere-else". Doesn't it >>> change what is returned from pwd? >>> >> >> Oh, it does. That's why the second patch (prefixed "[PATCH, fixed]"). >> It makes HOME to be "$(pwd)/somewhere-else", or precisely: >> >> HOME="$(pwd)"/"$test" >> export HOME > > What happens to people who has non-empty "$root", iow, their $test begins > with '/'? It's still under $test then. > I am not saying that having HOME at t/ directory instead of t/trash-*/ > directory would necessarily break things (I don't know). I am just > pointing out that the patch changes behaviour. It does. I still think we're better off using the test's trash directory for a this. For instance, consider the case when a user's .gitconfig created by one of the tests collides with .gitconfig's of the other tests. Either when running in parallel or just sequentially: the .gitconfig in "t/" is not cleaned up after a test finishes. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] HOME must be set before calling git-init when creating test repositories 2011-03-26 10:08 ` Alex Riesen @ 2011-03-26 14:11 ` Jeff King 2011-03-26 18:21 ` Alex Riesen 0 siblings, 1 reply; 14+ messages in thread From: Jeff King @ 2011-03-26 14:11 UTC (permalink / raw) To: Alex Riesen; +Cc: Junio C Hamano, git On Sat, Mar 26, 2011 at 11:08:06AM +0100, Alex Riesen wrote: > >> Oh, it does. That's why the second patch (prefixed "[PATCH, fixed]"). > >> It makes HOME to be "$(pwd)/somewhere-else", or precisely: > >> > >> HOME="$(pwd)"/"$test" > >> export HOME > > > > What happens to people who has non-empty "$root", iow, their $test begins > > with '/'? > > It's still under $test then. No, it's totally broken. $(pwd)/$test is nonsensical. The code right above your change guarantees that $test is an absolute path, either because the user gave us an absolute $root or because it has been prepended with $TEST_DIRECTORY (which itself comes from $(pwd)). So the change you want is HOME=$test. But note that the code looks like this then: HOME=$test export HOME test_create_repo "$test" cd -P "$test" meaning that test_create_repo sees a non-existent HOME. I don't think that matters, but if it did, you could do: HOME=$TEST_DIRECTORY export HOME test_create_repo "$test" cd -P "$test" HOME=$test -Peff ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH] HOME must be set before calling git-init when creating test repositories 2011-03-26 14:11 ` Jeff King @ 2011-03-26 18:21 ` Alex Riesen 2011-03-26 18:31 ` Jeff King 0 siblings, 1 reply; 14+ messages in thread From: Alex Riesen @ 2011-03-26 18:21 UTC (permalink / raw) To: Jeff King; +Cc: Junio C Hamano, git Otherwise the created test repositories will be affected by users ~/.gitconfig. For example, setting core.logAllrefupdates in users config will make all calls to "git config --unset core.logAllrefupdates" fail which will break the first test which uses the statement and expects it to succeed. Signed-off-by: Alex Riesen <raa.lkml@gmail.com> --- Jeff King, Sat, Mar 26, 2011 15:11:18 +0100: > On Sat, Mar 26, 2011 at 11:08:06AM +0100, Alex Riesen wrote: > > > >> Oh, it does. That's why the second patch (prefixed "[PATCH, fixed]"). > > >> It makes HOME to be "$(pwd)/somewhere-else", or precisely: > > >> > > >> HOME="$(pwd)"/"$test" > > >> export HOME > > > > > > What happens to people who has non-empty "$root", iow, their $test begins > > > with '/'? > > > > It's still under $test then. > > No, it's totally broken. $(pwd)/$test is nonsensical. The code right > above your change guarantees that $test is an absolute path, either > because the user gave us an absolute $root or because it has been > prepended with $TEST_DIRECTORY (which itself comes from $(pwd)). I see. I mistook "$root" for the root of a filesystem, not the variable in test-lib.sh. How about this, than? t/test-lib.sh | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/t/test-lib.sh b/t/test-lib.sh index 7cc9a52..2b24c3d 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -984,14 +984,15 @@ rm -fr "$test" || { exit 1 } +HOME="$(pwd)/$test" +test -n "$root" && HOME="$test" +export HOME + test_create_repo "$test" # Use -P to resolve symlinks in our working directory so that the cwd # in subprocesses like git equals our $PWD (for pathname comparisons). cd -P "$test" || exit 1 -HOME=$(pwd) -export HOME - this_test=${0##*/} this_test=${this_test%%-*} for skp in $GIT_SKIP_TESTS -- 1.7.4.1.471.gab01 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH] HOME must be set before calling git-init when creating test repositories 2011-03-26 18:21 ` Alex Riesen @ 2011-03-26 18:31 ` Jeff King 2011-03-26 18:42 ` Alex Riesen 0 siblings, 1 reply; 14+ messages in thread From: Jeff King @ 2011-03-26 18:31 UTC (permalink / raw) To: Alex Riesen; +Cc: Junio C Hamano, git On Sat, Mar 26, 2011 at 07:21:26PM +0100, Alex Riesen wrote: > > No, it's totally broken. $(pwd)/$test is nonsensical. The code right > > above your change guarantees that $test is an absolute path, either > > because the user gave us an absolute $root or because it has been > > prepended with $TEST_DIRECTORY (which itself comes from $(pwd)). > > I see. I mistook "$root" for the root of a filesystem, not the variable in > test-lib.sh. How about this, than? Oops, when I said "$test" I meant to say $TRASH_DIRECTORY. That is, $TRASH_DIRECTORY is always the absolute path to the trash. > +HOME="$(pwd)/$test" > +test -n "$root" && HOME="$test" > +export HOME So you can simplify this to just: HOME=$TRASH_DIRECTORY and not have to worry about checking $root at all. Sorry for the confusion. -Peff ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] HOME must be set before calling git-init when creating test repositories 2011-03-26 18:31 ` Jeff King @ 2011-03-26 18:42 ` Alex Riesen 2011-03-26 18:46 ` Alex Riesen 0 siblings, 1 reply; 14+ messages in thread From: Alex Riesen @ 2011-03-26 18:42 UTC (permalink / raw) To: Jeff King; +Cc: Junio C Hamano, git On Sat, Mar 26, 2011 at 19:31, Jeff King <peff@peff.net> wrote: > On Sat, Mar 26, 2011 at 07:21:26PM +0100, Alex Riesen wrote: > >> > No, it's totally broken. $(pwd)/$test is nonsensical. The code right >> > above your change guarantees that $test is an absolute path, either >> > because the user gave us an absolute $root or because it has been >> > prepended with $TEST_DIRECTORY (which itself comes from $(pwd)). >> >> I see. I mistook "$root" for the root of a filesystem, not the variable in >> test-lib.sh. How about this, than? > > Oops, when I said "$test" I meant to say $TRASH_DIRECTORY. That is, > $TRASH_DIRECTORY is always the absolute path to the trash. > >> +HOME="$(pwd)/$test" >> +test -n "$root" && HOME="$test" >> +export HOME > > So you can simplify this to just: > > HOME=$TRASH_DIRECTORY > Aah... I should have actually looked at the "case" which sets TRASH_DIRECTORY! Will resend in a moment. ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH] HOME must be set before calling git-init when creating test repositories 2011-03-26 18:42 ` Alex Riesen @ 2011-03-26 18:46 ` Alex Riesen 2011-03-26 18:48 ` Jeff King 0 siblings, 1 reply; 14+ messages in thread From: Alex Riesen @ 2011-03-26 18:46 UTC (permalink / raw) To: git; +Cc: Junio C Hamano, Jeff King Otherwise the created test repositories will be affected by users ~/.gitconfig. For example, setting core.logAllrefupdates in users config will make all calls to "git config --unset core.logAllrefupdates" fail which will break the first test which uses the statement and expects it to succeed. Signed-off-by: Alex Riesen <raa.lkml@gmail.com> --- Alex Riesen, Sat, Mar 26, 2011 19:42:14 +0100: > On Sat, Mar 26, 2011 at 19:31, Jeff King <peff@peff.net> wrote: > > > > So you can simplify this to just: > > > > HOME=$TRASH_DIRECTORY > > Aah... I should have actually looked at the "case" which > sets TRASH_DIRECTORY! > > Will resend in a moment. Here. t/test-lib.sh | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/t/test-lib.sh b/t/test-lib.sh index 7cc9a52..7965b74 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -984,14 +984,14 @@ rm -fr "$test" || { exit 1 } +HOME="$TRASH_DIRECTORY" +export HOME + test_create_repo "$test" # Use -P to resolve symlinks in our working directory so that the cwd # in subprocesses like git equals our $PWD (for pathname comparisons). cd -P "$test" || exit 1 -HOME=$(pwd) -export HOME - this_test=${0##*/} this_test=${this_test%%-*} for skp in $GIT_SKIP_TESTS -- 1.7.4.1.471.gab01 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH] HOME must be set before calling git-init when creating test repositories 2011-03-26 18:46 ` Alex Riesen @ 2011-03-26 18:48 ` Jeff King 0 siblings, 0 replies; 14+ messages in thread From: Jeff King @ 2011-03-26 18:48 UTC (permalink / raw) To: Alex Riesen; +Cc: git, Junio C Hamano On Sat, Mar 26, 2011 at 07:46:34PM +0100, Alex Riesen wrote: > diff --git a/t/test-lib.sh b/t/test-lib.sh > index 7cc9a52..7965b74 100644 > --- a/t/test-lib.sh > +++ b/t/test-lib.sh > @@ -984,14 +984,14 @@ rm -fr "$test" || { > exit 1 > } > > +HOME="$TRASH_DIRECTORY" > +export HOME > + > test_create_repo "$test" > # Use -P to resolve symlinks in our working directory so that the cwd > # in subprocesses like git equals our $PWD (for pathname comparisons). > cd -P "$test" || exit 1 > > -HOME=$(pwd) > -export HOME > - That looks right to me. Thanks. -Peff ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2011-03-26 18:48 UTC | newest] Thread overview: 14+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-03-25 20:05 [PATCH] HOME must be set before calling git-init when creating test repositories Alex Riesen 2011-03-25 20:44 ` [PATCH, fixed] " Alex Riesen 2011-03-25 20:49 ` [PATCH] " Junio C Hamano 2011-03-25 21:01 ` Alex Riesen 2011-03-25 21:30 ` Junio C Hamano 2011-03-25 21:51 ` Alex Riesen 2011-03-25 22:39 ` Junio C Hamano 2011-03-26 10:08 ` Alex Riesen 2011-03-26 14:11 ` Jeff King 2011-03-26 18:21 ` Alex Riesen 2011-03-26 18:31 ` Jeff King 2011-03-26 18:42 ` Alex Riesen 2011-03-26 18:46 ` Alex Riesen 2011-03-26 18:48 ` Jeff King
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox