submodule: export sanitized GIT_CONFIG_PARAMETERS
authorJeff King <peff@peff.net>
Thu, 28 Apr 2016 13:37:44 +0000 (09:37 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 28 Apr 2016 17:47:34 +0000 (10:47 -0700)
Commit 14111fc (git: submodule honor -c credential.* from
command line, 2016-02-29) taught git-submodule.sh to save
the sanitized value of $GIT_CONFIG_PARAMETERS when clearing
the environment for a submodule. However, it failed to
export the result, meaning that it had no effect for any
sub-programs.

We didn't catch this in our initial tests because we checked
only the "clone" case, which does not go through the shell
script at all. Provoking "git submodule update" to do a
fetch demonstrates the bug.

Noticed-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-submodule.sh
t/t5550-http-fetch-dumb.sh
index 1f132b489b81eb0bb7a4a6a5b7d3a5b88a77f53a..91f5856df8c2cb07c6d2849acfe9f107991e3763 100755 (executable)
@@ -200,6 +200,7 @@ sanitize_submodule_env()
        sanitized_config=$(git submodule--helper sanitize-config)
        clear_local_git_env
        GIT_CONFIG_PARAMETERS=$sanitized_config
+       export GIT_CONFIG_PARAMETERS
 }
 
 #
index e8e91bbb6d9fc5cabe9ce4e54ee76d88a89f8ed5..13ac788fde736002bccbf526cd06eef5594db814 100755 (executable)
@@ -112,6 +112,23 @@ test_expect_success 'cmdline credential config passes to submodule via clone' '
        expect_askpass pass user@host
 '
 
+test_expect_success 'cmdline credential config passes submodule update' '
+       # advance the submodule HEAD so that a fetch is required
+       git commit --allow-empty -m foo &&
+       git push "$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/repo.git" HEAD &&
+       sha1=$(git rev-parse HEAD) &&
+       git -C super-clone update-index --cacheinfo 160000,$sha1,sub &&
+
+       set_askpass wrong pass@host &&
+       test_must_fail git -C super-clone submodule update &&
+
+       set_askpass wrong pass@host &&
+       git -C super-clone \
+           -c "credential.$HTTPD_URL.username=user@host" \
+           submodule update &&
+       expect_askpass pass user@host
+'
+
 test_expect_success 'fetch changes via http' '
        echo content >>file &&
        git commit -a -m two &&