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

Re: [PATCH] config: use GIT_CONFIG in git config sequence

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Apr 26, 2020, 20:08 UTC
Message-ID
<20200426200845.GE6421@camp.crustytoothpaste.net>
In-Reply-To
<5c1005a7-273e-fab0-0d0d-78bd0d3d13f6@gmail.com>
On 2020-04-26 at 19:32:05, Mateusz Nowotyński wrote:
Show 9 quoted lines
> On Sat, Apr 25, 2020 at 05:16:56PM -0700, Junio C Hamano wrote:
> > You can prepare a pretend-home directory for the use of your tests
> > and point the environment variable $HOME to it while running your
> > tests.  See how we do this in our test suite for inspiration---it
> > all happens in t/test-lib.sh, I think.
> 
> This is what we do currently but the problem with this solution is that
> it breaks other software that also uses HOME as base path for their
> data. For example asdf version manager.

I know nothing about the asdf version manager, but if you're relying on it for programs, those programs should end up in PATH, and when invoked appropriately in those locations, those programs should just work, regardless of what $HOME is set to. If they don't, that would be a defect in asdf, since the Unix expectation is that programs in $PATH should generally function without regard to the setting of $HOME. From my cursory poking around at the repo, it looks like it should do this just fine.

So you can set $HOME to a temporary directory and still use asdf as long as your don't reset $PATH. Or, if you want to specifically load asdf programs first, you could do something like this:

  #!/bin/sh
  . "$HOME/asdf/asdf.sh"
  export HOME=$(mktemp -d)
  # Run tests here.

Regardless of your tooling, you definitely want to reset $HOME in almost every nontrivial shell testsuite, since many users have configuration files or data storage that you wouldn't want to use. For example, if you generate a new GnuPG key on every run, the user won't appreciate it if you import it as one of their private keys.

-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204
Previous: Mateusz NowotyńskiNext: Mateusz Nowotynski
Message 5 of 14 in “config: use GIT_CONFIG in git config sequence”
  1. config: use GIT_CONFIG in git config sequenceMateusz Nowotyński, Apr 25, 2020
  2. Junio C HamanoApr 26, 2020
  3. Philip OakleyApr 26, 2020
  4. Mateusz NowotyńskiApr 26, 2020
  5. brian m. carlsonApr 26, 2020
  6. Mateusz NowotynskiApr 27, 2020
  7. Junio C HamanoApr 26, 2020
  8. Matt RogersApr 26, 2020
  9. Philip OakleyApr 26, 2020
  10. Matt RogersApr 26, 2020
  11. Philip OakleyApr 26, 2020
  12. Junio C HamanoApr 26, 2020
  13. Junio C HamanoApr 26, 2020
  14. Mateusz NowotynskiApr 27, 2020

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.