From 06eb708f331f0829081f4f3fb3c465eaae345deb Mon Sep 17 00:00:00 2001 From: Jeff King Date: Tue, 24 May 2011 18:49:55 -0400 Subject: config: always parse GIT_CONFIG_PARAMETERS during git_config Previously we parsed GIT_CONFIG_PARAMETERS lazily into a linked list, and then checked that list during future invocations of git_config. However, that ignores the fact that the environment variable could change during our run (e.g., because we parse more "-c" as part of an alias). Instead, let's just re-parse the environment variable each time. It's generally not very big, and it's no more work than parsing the config files, anyway. As a bonus, we can ditch all of the linked list storage code entirely, making the code much simpler. The test unfortunately still does not pass because of an unrelated bug in handle_options. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/t1300-repo-config.sh | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 't') diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh index d0ab8ffe1b..52c9ac9b65 100755 --- a/t/t1300-repo-config.sh +++ b/t/t1300-repo-config.sh @@ -854,4 +854,11 @@ test_expect_success 'git -c "key=value" support' ' test_must_fail git -c core.name=value config name ' +test_expect_failure 'git -c works with aliases of builtins' ' + git config alias.checkconfig "-c foo.check=bar config foo.check" && + echo bar >expect && + git checkconfig >actual && + test_cmp expect actual +' + test_done -- cgit v1.2.1 From 73546c085d49694c5e54b421f80bde6bc25006fb Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 24 May 2011 18:50:35 -0400 Subject: handle_options(): do not miscount how many arguments were used The handle_options() function advances the base of the argument array and returns the number of arguments it used. The caller in handle_alias() wants to reallocate the argv array it passes to this function, and attempts to do so by subtracting the returned value to compensate for the change handle_options() makes to the new_argv. But handle_options() did not correctly count when "-c " is given, causing a wrong pointer to be passed to realloc(). Fix it by saving the original argv at the beginning of handle_options(), and return the difference between the final value of argv, which will relieve the places that move the array pointer from the additional burden of keeping track of "handled" counter. Noticed-by: Kazuki Tsujimoto Signed-off-by: Junio C Hamano Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/t1300-repo-config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't') diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh index 52c9ac9b65..de2a014d8f 100755 --- a/t/t1300-repo-config.sh +++ b/t/t1300-repo-config.sh @@ -854,7 +854,7 @@ test_expect_success 'git -c "key=value" support' ' test_must_fail git -c core.name=value config name ' -test_expect_failure 'git -c works with aliases of builtins' ' +test_expect_success 'git -c works with aliases of builtins' ' git config alias.checkconfig "-c foo.check=bar config foo.check" && echo bar >expect && git checkconfig >actual && -- cgit v1.2.1