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

Re: [PATCH v2 3/3] config: correct file reading order in read_early_config()

From
Jeff King <peff@peff.net>
Date
Apr 18, 2017, 03:53 UTC
Message-ID
<20170418035344.feu27cwogvdbdwyj@sigill.intra.peff.net>
In-Reply-To
<20170417101002.18272-3-pclouds@gmail.com>
On Mon, Apr 17, 2017 at 05:10:02PM +0700, Nguyễn Thái Ngọc Duy wrote:
Show 12 quoted lines
> diff --git a/t/helper/test-config.c b/t/helper/test-config.c
> index 8e3ed6a76c..696d0a52fd 100644
> --- a/t/helper/test-config.c
> +++ b/t/helper/test-config.c
> @@ -84,6 +84,10 @@ int cmd_main(int argc, const char **argv)
>  	struct config_set cs;
>  
>  	if (argc == 3 && !strcmp(argv[1], "read_early_config")) {
> +		const char *cmdline_config = getenv("CMDL_CFG");
> +
> +		if (cmdline_config)
> +			git_config_push_parameter(cmdline_config);
I think you can do without this hunk by just setting:
  GIT_CONFIG_PARAMETERS="'foo.bar=from-cmdline'"
(note the single-quotes which must be there). See how t1308 does it.
Show 16 quoted lines
> +test_expect_success 'read config file in right order' '
> +	echo "[test]source = home" >>.gitconfig &&
> +	git init foo &&
> +	(
> +		cd foo &&
> +		echo "[test]source = repo" >>.git/config &&
> +		CMDL_CFG=test.source=cmdline test-config \
> +			read_early_config test.source >actual &&
> +		cat >expected <<-\EOF &&
> +		home
> +		repo
> +		cmdline
> +		EOF
> +		test_cmp expected actual
> +	)
> +'
This looks good (modulo the CMDL_CFG above).

If we wanted to trigger it in a real-world test, we'd have to use pager config (since it's the only thing that uses early-config; alias lookup probably should do, but that's for another time). But I think this synthetic test is fine; it makes the output easy to verify.

-Peff
Previous: Nguyễn Thái Ngọc DuyNext: Junio C Hamano
Message 17 of 24 in “includeIf breaks calling dashed externals”
  1. Bert WesargApr 14, 2017
  2. Jeff KingApr 14, 2017
  3. Duy NguyenApr 15, 2017
  4. Jeff KingApr 16, 2017
  5. 1/2 config: prepare to pass more info in git_config_with_options()Nguyễn Thái Ngọc Duy, Apr 16, 2017
  6. 2/2 config: handle conditional include when $GIT_DIR is not set upNguyễn Thái Ngọc Duy, Apr 16, 2017
  7. Jeff KingApr 16, 2017
  8. Duy NguyenApr 17, 2017
  9. Jeff KingApr 18, 2017
  10. Duy NguyenApr 17, 2017
  11. 1/3 config: prepare to pass more info in git_config_with_options()Nguyễn Thái Ngọc Duy, Apr 17, 2017
  12. 2/3 config: handle conditional include when $GIT_DIR is not set upNguyễn Thái Ngọc Duy, Apr 17, 2017
  13. Junio C HamanoApr 18, 2017
  14. Junio C HamanoApr 18, 2017
  15. Jeff KingApr 18, 2017
  16. 3/3 config: correct file reading order in read_early_config()Nguyễn Thái Ngọc Duy, Apr 17, 2017
  17. Jeff KingApr 18, 2017
  18. Junio C HamanoApr 18, 2017
  19. Jeff KingApr 18, 2017
  20. Junio C HamanoApr 18, 2017
  21. Junio C HamanoApr 18, 2017
  22. Jeff KingApr 18, 2017
  23. Jeff KingApr 16, 2017
  24. Duy NguyenApr 17, 2017

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.