Skip to content

Commit

Permalink
Merge branch 'jn/test-sanitize-git-env'
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Junio C Hamano committed Mar 23, 2011
2 parents f59bf09 + 95a1d12 commit 50aaeca
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 47 deletions.
7 changes: 1 addition & 6 deletions attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,11 +478,6 @@ int git_attr_system(void)
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)
{
if (!strcmp(var, "core.attributesfile"))
Expand Down Expand Up @@ -511,7 +506,7 @@ static void bootstrap_attr_stack(void)
}

git_config(git_attr_config, NULL);
if (git_attr_global() && attributes_file) {
if (attributes_file) {
elem = read_attr_from_file(attributes_file, 1);
if (elem) {
elem->origin = NULL;
Expand Down
2 changes: 1 addition & 1 deletion builtin/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ static int get_value(const char *key_, const char *regex_)
if (!local) {
const char *home = getenv("HOME");
local = repo_config = git_pathdup("config");
if (git_config_global() && home)
if (home)
global = xstrdup(mkpath("%s/.gitconfig", home));
if (git_config_system())
system_wide = git_etc_gitconfig();
Expand Down
1 change: 0 additions & 1 deletion cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 git_env_bool(const char *, int);
extern int git_config_system(void);
extern int git_config_global(void);
extern int config_error_nonbool(const char *);
extern const char *get_log_output_encoding(void);
extern const char *get_commit_output_encoding(void);
Expand Down
7 changes: 1 addition & 6 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -825,11 +825,6 @@ int git_config_system(void)
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)
{
static int loaded_environment;
Expand Down Expand Up @@ -861,7 +856,7 @@ int git_config_early(config_fn_t fn, void *data, const char *repo_config)
}

home = getenv("HOME");
if (git_config_global() && home) {
if (home) {
char *user_config = xstrdup(mkpath("%s/.gitconfig", home));
if (!access(user_config, R_OK)) {
ret += git_config_from_file(fn, user_config, data);
Expand Down
5 changes: 1 addition & 4 deletions t/t0001-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ test_expect_success 'plain nested in bare' '

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 &&
export HOME &&
mkdir alias-config &&
Expand Down Expand Up @@ -231,7 +231,6 @@ test_expect_success 'init with init.templatedir set' '
git config -f "$test_config" init.templatedir "${HOME}/templatedir-source" &&
mkdir templatedir-set &&
cd templatedir-set &&
sane_unset GIT_CONFIG_NOGLOBAL &&
sane_unset GIT_TEMPLATE_DIR &&
NO_SET_GIT_TEMPLATE_DIR=t &&
export NO_SET_GIT_TEMPLATE_DIR &&
Expand All @@ -243,7 +242,6 @@ test_expect_success 'init with init.templatedir set' '
test_expect_success 'init --bare/--shared overrides system/global config' '
(
test_config="$HOME"/.gitconfig &&
sane_unset GIT_CONFIG_NOGLOBAL &&
git config -f "$test_config" core.bare false &&
git config -f "$test_config" core.sharedRepository 0640 &&
mkdir init-bare-shared-override &&
Expand All @@ -258,7 +256,6 @@ test_expect_success 'init --bare/--shared overrides system/global config' '
test_expect_success 'init honors global core.sharedRepository' '
(
test_config="$HOME"/.gitconfig &&
sane_unset GIT_CONFIG_NOGLOBAL &&
git config -f "$test_config" core.sharedRepository 0666 &&
mkdir shared-honor-global &&
cd shared-honor-global &&
Expand Down
1 change: 0 additions & 1 deletion t/t5601-clone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ test_expect_success 'clone a void' '
test_expect_success 'clone respects global branch.autosetuprebase' '
(
test_config="$HOME/.gitconfig" &&
unset GIT_CONFIG_NOGLOBAL &&
git config -f "$test_config" branch.autosetuprebase remote &&
rm -fr dst &&
git clone src dst &&
Expand Down
1 change: 0 additions & 1 deletion t/t9130-git-svn-authors-file.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ test_expect_success 'fresh clone with svn.authors-file in config' '
rm -r "$GIT_DIR" &&
test x = x"$(git config svn.authorsfile)" &&
test_config="$HOME"/.gitconfig &&
unset GIT_CONFIG_NOGLOBAL &&
unset GIT_DIR &&
unset GIT_CONFIG &&
git config --global \
Expand Down
34 changes: 7 additions & 27 deletions t/test-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,36 +43,16 @@ TERM=dumb
export LANG LC_ALL PAGER TERM TZ
EDITOR=:
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 GIT_ALTERNATE_OBJECT_DIRECTORIES
unset GIT_AUTHOR_DATE
unset $(perl -e '
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_NAME='A U Thor'
unset GIT_COMMITTER_DATE
GIT_COMMITTER_EMAIL=committer@example.com
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
export GIT_MERGE_VERBOSITY
export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME
Expand Down Expand Up @@ -954,8 +934,8 @@ fi
GIT_TEMPLATE_DIR="$GIT_BUILD_DIR"/templates/blt
unset GIT_CONFIG
GIT_CONFIG_NOSYSTEM=1
GIT_CONFIG_NOGLOBAL=1
export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG_NOSYSTEM GIT_CONFIG_NOGLOBAL
GIT_ATTR_NOSYSTEM=1
export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG_NOSYSTEM GIT_ATTR_NOSYSTEM

. "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS

Expand Down

0 comments on commit 50aaeca

Please sign in to comment.