mirror of
https://github.com/git/git
synced 2024-08-24 18:26:02 +00:00
![Jacob Keller](/assets/img/avatar_default.png)
Due to the way that the git-submodule code works, it clears all local git environment variables before entering submodules. This is normally a good thing since we want to clear settings such as GIT_WORKTREE and other variables which would affect the operation of submodule commands. However, GIT_CONFIG_PARAMETERS is special, and we actually do want to preserve these settings. However, we do not want to preserve all configuration as many things should be left specific to the parent project. Add a git submodule--helper function, sanitize-config, which shall be used to sanitize GIT_CONFIG_PARAMETERS, removing all key/value pairs except a small subset that are known to be safe and necessary. Replace all the calls to clear_local_git_env with a wrapped function that filters GIT_CONFIG_PARAMETERS using the new helper and then restores it to the filtered subset after clearing the rest of the environment. Signed-off-by: Jacob Keller <jacob.keller@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
27 lines
629 B
Bash
Executable file
27 lines
629 B
Bash
Executable file
#!/bin/sh
|
|
#
|
|
# Copyright (c) 2016 Jacob Keller
|
|
#
|
|
|
|
test_description='Basic plumbing support of submodule--helper
|
|
|
|
This test verifies the submodule--helper plumbing command used to implement
|
|
git-submodule.
|
|
'
|
|
|
|
. ./test-lib.sh
|
|
|
|
test_expect_success 'sanitize-config clears configuration' '
|
|
git -c user.name="Some User" submodule--helper sanitize-config >actual &&
|
|
test_must_be_empty actual
|
|
'
|
|
|
|
sq="'"
|
|
test_expect_success 'sanitize-config keeps credential.helper' '
|
|
git -c credential.helper=helper submodule--helper sanitize-config >actual &&
|
|
echo "${sq}credential.helper=helper${sq}" >expect &&
|
|
test_cmp expect actual
|
|
'
|
|
|
|
test_done
|