On Mon, Apr 17, 2017 at 05:10:02PM +0700, Nguyễn Thái Ngọc Duy wrote:
> 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.
> +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