Merge branch 'jn/test-sanitize-git-env'

* jn/test-sanitize-git-env:
  tests: scrub environment of GIT_* variables
  config: drop support for GIT_CONFIG_NOGLOBAL
  gitattributes: drop support for GIT_ATTR_NOGLOBAL
  tests: suppress system gitattributes
  tests: stop worrying about obsolete environment variables
This commit is contained in:
Junio C Hamano 2011-03-22 21:38:12 -07:00
commit 50aaeca008
8 changed files with 11 additions and 47 deletions

7
attr.c
View File

@ -478,11 +478,6 @@ int git_attr_system(void)
return !git_env_bool("GIT_ATTR_NOSYSTEM", 0); return !git_env_bool("GIT_ATTR_NOSYSTEM", 0);
} }
int git_attr_global(void)
{
return !git_env_bool("GIT_ATTR_NOGLOBAL", 0);
}
static int git_attr_config(const char *var, const char *value, void *dummy) static int git_attr_config(const char *var, const char *value, void *dummy)
{ {
if (!strcmp(var, "core.attributesfile")) if (!strcmp(var, "core.attributesfile"))
@ -511,7 +506,7 @@ static void bootstrap_attr_stack(void)
} }
git_config(git_attr_config, NULL); git_config(git_attr_config, NULL);
if (git_attr_global() && attributes_file) { if (attributes_file) {
elem = read_attr_from_file(attributes_file, 1); elem = read_attr_from_file(attributes_file, 1);
if (elem) { if (elem) {
elem->origin = NULL; elem->origin = NULL;

View File

@ -160,7 +160,7 @@ static int get_value(const char *key_, const char *regex_)
if (!local) { if (!local) {
const char *home = getenv("HOME"); const char *home = getenv("HOME");
local = repo_config = git_pathdup("config"); local = repo_config = git_pathdup("config");
if (git_config_global() && home) if (home)
global = xstrdup(mkpath("%s/.gitconfig", home)); global = xstrdup(mkpath("%s/.gitconfig", home));
if (git_config_system()) if (git_config_system())
system_wide = git_etc_gitconfig(); system_wide = git_etc_gitconfig();

View File

@ -1022,7 +1022,6 @@ extern const char *git_etc_gitconfig(void);
extern int check_repository_format_version(const char *var, const char *value, void *cb); extern int check_repository_format_version(const char *var, const char *value, void *cb);
extern int git_env_bool(const char *, int); extern int git_env_bool(const char *, int);
extern int git_config_system(void); extern int git_config_system(void);
extern int git_config_global(void);
extern int config_error_nonbool(const char *); extern int config_error_nonbool(const char *);
extern const char *get_log_output_encoding(void); extern const char *get_log_output_encoding(void);
extern const char *get_commit_output_encoding(void); extern const char *get_commit_output_encoding(void);

View File

@ -825,11 +825,6 @@ int git_config_system(void)
return !git_env_bool("GIT_CONFIG_NOSYSTEM", 0); return !git_env_bool("GIT_CONFIG_NOSYSTEM", 0);
} }
int git_config_global(void)
{
return !git_env_bool("GIT_CONFIG_NOGLOBAL", 0);
}
int git_config_from_parameters(config_fn_t fn, void *data) int git_config_from_parameters(config_fn_t fn, void *data)
{ {
static int loaded_environment; static int loaded_environment;
@ -861,7 +856,7 @@ int git_config_early(config_fn_t fn, void *data, const char *repo_config)
} }
home = getenv("HOME"); home = getenv("HOME");
if (git_config_global() && home) { if (home) {
char *user_config = xstrdup(mkpath("%s/.gitconfig", home)); char *user_config = xstrdup(mkpath("%s/.gitconfig", home));
if (!access(user_config, R_OK)) { if (!access(user_config, R_OK)) {
ret += git_config_from_file(fn, user_config, data); ret += git_config_from_file(fn, user_config, data);

View File

@ -47,7 +47,7 @@ test_expect_success 'plain nested in bare' '
test_expect_success 'plain through aliased command, outside any git repo' ' test_expect_success 'plain through aliased command, outside any git repo' '
( (
sane_unset GIT_DIR GIT_WORK_TREE GIT_CONFIG_NOGLOBAL && sane_unset GIT_DIR GIT_WORK_TREE &&
HOME=$(pwd)/alias-config && HOME=$(pwd)/alias-config &&
export HOME && export HOME &&
mkdir alias-config && mkdir alias-config &&
@ -231,7 +231,6 @@ test_expect_success 'init with init.templatedir set' '
git config -f "$test_config" init.templatedir "${HOME}/templatedir-source" && git config -f "$test_config" init.templatedir "${HOME}/templatedir-source" &&
mkdir templatedir-set && mkdir templatedir-set &&
cd templatedir-set && cd templatedir-set &&
sane_unset GIT_CONFIG_NOGLOBAL &&
sane_unset GIT_TEMPLATE_DIR && sane_unset GIT_TEMPLATE_DIR &&
NO_SET_GIT_TEMPLATE_DIR=t && NO_SET_GIT_TEMPLATE_DIR=t &&
export NO_SET_GIT_TEMPLATE_DIR && export NO_SET_GIT_TEMPLATE_DIR &&
@ -243,7 +242,6 @@ test_expect_success 'init with init.templatedir set' '
test_expect_success 'init --bare/--shared overrides system/global config' ' test_expect_success 'init --bare/--shared overrides system/global config' '
( (
test_config="$HOME"/.gitconfig && test_config="$HOME"/.gitconfig &&
sane_unset GIT_CONFIG_NOGLOBAL &&
git config -f "$test_config" core.bare false && git config -f "$test_config" core.bare false &&
git config -f "$test_config" core.sharedRepository 0640 && git config -f "$test_config" core.sharedRepository 0640 &&
mkdir init-bare-shared-override && mkdir init-bare-shared-override &&
@ -258,7 +256,6 @@ test_expect_success 'init --bare/--shared overrides system/global config' '
test_expect_success 'init honors global core.sharedRepository' ' test_expect_success 'init honors global core.sharedRepository' '
( (
test_config="$HOME"/.gitconfig && test_config="$HOME"/.gitconfig &&
sane_unset GIT_CONFIG_NOGLOBAL &&
git config -f "$test_config" core.sharedRepository 0666 && git config -f "$test_config" core.sharedRepository 0666 &&
mkdir shared-honor-global && mkdir shared-honor-global &&
cd shared-honor-global && cd shared-honor-global &&

View File

@ -164,7 +164,6 @@ test_expect_success 'clone a void' '
test_expect_success 'clone respects global branch.autosetuprebase' ' test_expect_success 'clone respects global branch.autosetuprebase' '
( (
test_config="$HOME/.gitconfig" && test_config="$HOME/.gitconfig" &&
unset GIT_CONFIG_NOGLOBAL &&
git config -f "$test_config" branch.autosetuprebase remote && git config -f "$test_config" branch.autosetuprebase remote &&
rm -fr dst && rm -fr dst &&
git clone src dst && git clone src dst &&

View File

@ -96,7 +96,6 @@ test_expect_success 'fresh clone with svn.authors-file in config' '
rm -r "$GIT_DIR" && rm -r "$GIT_DIR" &&
test x = x"$(git config svn.authorsfile)" && test x = x"$(git config svn.authorsfile)" &&
test_config="$HOME"/.gitconfig && test_config="$HOME"/.gitconfig &&
unset GIT_CONFIG_NOGLOBAL &&
unset GIT_DIR && unset GIT_DIR &&
unset GIT_CONFIG && unset GIT_CONFIG &&
git config --global \ git config --global \

View File

@ -43,36 +43,16 @@ TERM=dumb
export LANG LC_ALL PAGER TERM TZ export LANG LC_ALL PAGER TERM TZ
EDITOR=: EDITOR=:
unset VISUAL unset VISUAL
unset GIT_EDITOR
unset AUTHOR_DATE
unset AUTHOR_EMAIL
unset AUTHOR_NAME
unset COMMIT_AUTHOR_EMAIL
unset COMMIT_AUTHOR_NAME
unset EMAIL unset EMAIL
unset GIT_ALTERNATE_OBJECT_DIRECTORIES unset $(perl -e '
unset GIT_AUTHOR_DATE my @env = keys %ENV;
my @vars = grep(/^GIT_/ && !/^GIT_(TRACE|DEBUG|USE_LOOKUP)/, @env);
print join("\n", @vars);
')
GIT_AUTHOR_EMAIL=author@example.com GIT_AUTHOR_EMAIL=author@example.com
GIT_AUTHOR_NAME='A U Thor' GIT_AUTHOR_NAME='A U Thor'
unset GIT_COMMITTER_DATE
GIT_COMMITTER_EMAIL=committer@example.com GIT_COMMITTER_EMAIL=committer@example.com
GIT_COMMITTER_NAME='C O Mitter' GIT_COMMITTER_NAME='C O Mitter'
unset GIT_DIFF_OPTS
unset GIT_DIR
unset GIT_WORK_TREE
unset GIT_EXTERNAL_DIFF
unset GIT_INDEX_FILE
unset GIT_OBJECT_DIRECTORY
unset GIT_CEILING_DIRECTORIES
unset SHA1_FILE_DIRECTORIES
unset SHA1_FILE_DIRECTORY
unset GIT_NOTES_REF
unset GIT_NOTES_DISPLAY_REF
unset GIT_NOTES_REWRITE_REF
unset GIT_NOTES_REWRITE_MODE
unset GIT_REFLOG_ACTION
unset GIT_CHERRY_PICK_HELP
unset GIT_QUIET
GIT_MERGE_VERBOSITY=5 GIT_MERGE_VERBOSITY=5
export GIT_MERGE_VERBOSITY export GIT_MERGE_VERBOSITY
export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME
@ -954,8 +934,8 @@ fi
GIT_TEMPLATE_DIR="$GIT_BUILD_DIR"/templates/blt GIT_TEMPLATE_DIR="$GIT_BUILD_DIR"/templates/blt
unset GIT_CONFIG unset GIT_CONFIG
GIT_CONFIG_NOSYSTEM=1 GIT_CONFIG_NOSYSTEM=1
GIT_CONFIG_NOGLOBAL=1 GIT_ATTR_NOSYSTEM=1
export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG_NOSYSTEM GIT_CONFIG_NOGLOBAL export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG_NOSYSTEM GIT_ATTR_NOSYSTEM
. "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS . "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS