Skip to content

Commit 5b94a77

Browse files
peffdscho
authored andcommitted
submodule: export sanitized GIT_CONFIG_PARAMETERS
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 <[email protected]> Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 05cd3a0 commit 5b94a77

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

git-submodule.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ sanitize_submodule_env()
200200
sanitized_config=$(git submodule--helper sanitize-config)
201201
clear_local_git_env
202202
GIT_CONFIG_PARAMETERS=$sanitized_config
203+
export GIT_CONFIG_PARAMETERS
203204
}
204205

205206
#

t/t5550-http-fetch-dumb.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,23 @@ test_expect_success 'cmdline credential config passes to submodule via clone' '
112112
expect_askpass pass user@host
113113
'
114114

115+
test_expect_success 'cmdline credential config passes submodule update' '
116+
# advance the submodule HEAD so that a fetch is required
117+
git commit --allow-empty -m foo &&
118+
git push "$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/repo.git" HEAD &&
119+
sha1=$(git rev-parse HEAD) &&
120+
git -C super-clone update-index --cacheinfo 160000,$sha1,sub &&
121+
122+
set_askpass wrong pass@host &&
123+
test_must_fail git -C super-clone submodule update &&
124+
125+
set_askpass wrong pass@host &&
126+
git -C super-clone \
127+
-c "credential.$HTTPD_URL.username=user@host" \
128+
submodule update &&
129+
expect_askpass pass user@host
130+
'
131+
115132
test_expect_success 'fetch changes via http' '
116133
echo content >>file &&
117134
git commit -a -m two &&

0 commit comments

Comments
 (0)