git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] HOME must be set before calling git-init when creating test repositories

From
Alex Riesen <raa.lkml@gmail.com>
Date
Mar 26, 2011, 18:21 UTC
Message-ID
<20110326182126.GA13496@blimp.localdomain>
In-Reply-To
<20110326141118.GA3475@sigill.intra.peff.net>

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:
Show 17 quoted lines
> 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
Previous: Jeff KingNext: Jeff King
Message 10 of 14 in “HOME must be set before calling git-init when creating test repositories”
  1. HOME must be set before calling git-init when creating test repositoriesAlex Riesen, Mar 25, 2011
  2. HOME must be set before calling git-init when creating test repositoriesAlex Riesen, Mar 25, 2011
  3. Junio C HamanoMar 25, 2011
  4. Alex RiesenMar 25, 2011
  5. Junio C HamanoMar 25, 2011
  6. Alex RiesenMar 25, 2011
  7. Junio C HamanoMar 25, 2011
  8. Alex RiesenMar 26, 2011
  9. Jeff KingMar 26, 2011
  10. HOME must be set before calling git-init when creating test repositoriesAlex Riesen, Mar 26, 2011
  11. Jeff KingMar 26, 2011
  12. Alex RiesenMar 26, 2011
  13. HOME must be set before calling git-init when creating test repositoriesAlex Riesen, Mar 26, 2011
  14. Jeff KingMar 26, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.