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

Re: [PATCH 04/12] t: stop using GIT_CONFIG to cross repo boundaries

From
Jeff King <peff@peff.net>
Date
Mar 24, 2014, 22:00 UTC
Message-ID
<20140324220011.GI13728@sigill.intra.peff.net>
In-Reply-To
<xmqqtxars0ph.fsf@gitster.dls.corp.google.com>
On Fri, Mar 21, 2014 at 02:26:02PM -0700, Junio C Hamano wrote:
Show 19 quoted lines
> Jeff King <peff@peff.net> writes:
> 
> > Some tests want to check or set config in another
> > repository. E.g., t1000 creates repositories and makes sure
> > that their core.bare and core.worktree settings are what we
> > expect. We can do this with:
> >
> >   GIT_CONFIG=$repo/.git/config git config ...
> >
> > but it better shows the intent to just enter the repository
> > and let "git config" do the normal lookups:
> >
> >   (cd $repo && git config ...)
> >
> > In theory, this would cause us to use an extra subshell, but
> > in all such cases, we are actually already in a subshell.
> 
> Sure; alternatively we could use "git -C $there", but this rewrite
> is fine by me.

The existing callers all pass actual $GIT_DIRs, so I initially wrote it as "git --git-dir=$repo config ...". Doing it as "-C" is perhaps nicer, as callers could potentially pass a shorter string to the repo root, and not bother with adding "/.git". However, t0001 needs the actual $GIT_DIR (because it looks for things like the refs/ directory in the same function), and the other callers are just passing bare repos.

So I'm fine with any of them. Feel free to mark it up if you have a preference.

-Peff
Previous: Junio C HamanoNext: Jeff King
Message 17 of 28 in “tests: set temp variables using 'env' in test function instead of subshell”
  1. tests: set temp variables using 'env' in test function instead of subshellDavid Tran, Mar 18, 2014
  2. Junio C HamanoMar 18, 2014
  3. Jeff KingMar 18, 2014
  4. Junio C HamanoMar 18, 2014
  5. Jeff KingMar 18, 2014
  6. Junio C HamanoMar 19, 2014
  7. 0/12 GIT_CONFIG in the test suiteJeff King, Mar 20, 2014
  8. 01/12 t/Makefile: stop setting GIT_CONFIGJeff King, Mar 20, 2014
  9. 02/12 t/test-lib: drop redundant unset of GIT_CONFIGJeff King, Mar 20, 2014
  10. 03/12 t: drop useless sane_unset GIT_* callsJeff King, Mar 20, 2014
  11. Junio C HamanoMar 21, 2014
  12. Jeff KingMar 24, 2014
  13. Junio C HamanoMar 24, 2014
  14. Junio C HamanoMar 25, 2014
  15. 04/12 t: stop using GIT_CONFIG to cross repo boundariesJeff King, Mar 20, 2014
  16. Junio C HamanoMar 21, 2014
  17. Jeff KingMar 24, 2014
  18. 05/12 t: prefer "git config --file" to GIT_CONFIG with test_must_failJeff King, Mar 20, 2014
  19. 06/12 t: prefer "git config --file" to GIT_CONFIGJeff King, Mar 20, 2014
  20. 07/12 t0001: make symlink reinit test more carefulJeff King, Mar 20, 2014
  21. 08/12 t0001: use test_path_is_*Jeff King, Mar 20, 2014
  22. 09/12 t0001: use test_config_globalJeff King, Mar 20, 2014
  23. 10/12 t0001: use test_must_failJeff King, Mar 20, 2014
  24. 11/12 t0001: drop useless subshellsJeff King, Mar 20, 2014
  25. Eric SunshineMar 21, 2014
  26. 12/12 t0001: drop subshells just for "cd"Jeff King, Mar 20, 2014
  27. Eric SunshineMar 18, 2014
  28. Eric SunshineMar 18, 2014

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.