From 67e6d817945202427977cf950b5ccbad3060e9e4 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Tue, 15 Mar 2011 05:09:24 -0500 Subject: tests: stop worrying about obsolete environment variables After v0.99.7~99 (Retire support for old environment variables, 2005-09-09), there is no more need to unset a stray AUTHOR_NAME variable that might have entered the test environment. Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano diff --git a/t/test-lib.sh b/t/test-lib.sh index 0fdc541..e381166 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -44,11 +44,6 @@ 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 @@ -64,8 +59,6 @@ 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 -- cgit v0.10.2-6-g49f6 From 3c995beb14b7aef9fa724cde9d2b7a4ea4ae53cc Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Tue, 15 Mar 2011 04:05:10 -0500 Subject: tests: suppress system gitattributes Set GIT_ATTR_NOSYSTEM in test-lib to make tests more reliable in two ways: - an invalid GIT_ATTR_NOSYSTEM setting should not cause tests to fail with "fatal: bad config value for 'GIT_ATTR_NOSYSTEM'". - /etc/gitattributes should not change the outcome of tests. Signed-off-by: Jonathan Nieder Improved-by: Jeff King Signed-off-by: Junio C Hamano diff --git a/t/test-lib.sh b/t/test-lib.sh index e381166..00f23fc 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -948,7 +948,8 @@ 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_CONFIG_NOGLOBAL GIT_ATTR_NOSYSTEM . "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS -- cgit v0.10.2-6-g49f6 From e91b6c504961a147f0ab4e2fc05be914f881290a Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Tue, 15 Mar 2011 04:04:15 -0500 Subject: gitattributes: drop support for GIT_ATTR_NOGLOBAL test-lib sets $HOME to protect against pollution from user settings, so setting GIT_ATTR_NOGLOBAL would be redundant. Simplify by eliminating support for that environment variable altogether. GIT_ATTR_NOGLOBAL was introduced in v1.7.4-rc0~208^2 (Add global and system-wide gitattributes, 2010-09-01) as an undocumented feature for use by the test suite. It never ended up being used (neither within git.git nor in other projects). This patch does not affect GIT_ATTR_NOSYSTEM, which should still be useful. Helped-by: Jeff King Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano diff --git a/attr.c b/attr.c index 6aff695..0e28ba8 100644 --- a/attr.c +++ b/attr.c @@ -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")) @@ -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; -- cgit v0.10.2-6-g49f6 From 8f323c00dd3c9b396b01a1aeea74f7dfd061bb7f Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Tue, 15 Mar 2011 04:04:49 -0500 Subject: config: drop support for GIT_CONFIG_NOGLOBAL Now that test-lib sets $HOME to protect against pollution from user settings, GIT_CONFIG_NOGLOBAL is not needed for use by the test suite any more. And as luck would have it, a quick code search reveals no other users in the wild. This patch does not affect GIT_CONFIG_NOSYSTEM, which is still needed. Helped-by: Jeff King Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano diff --git a/builtin/config.c b/builtin/config.c index 76be0b7..3e3c528 100644 --- a/builtin/config.c +++ b/builtin/config.c @@ -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(); diff --git a/cache.h b/cache.h index d0bbc91..a8ef37a 100644 --- a/cache.h +++ b/cache.h @@ -1020,7 +1020,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); diff --git a/config.c b/config.c index b94de8f..217a77d 100644 --- a/config.c +++ b/config.c @@ -826,11 +826,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; @@ -862,7 +857,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); diff --git a/t/t0001-init.sh b/t/t0001-init.sh index f684993..ce4ba13 100755 --- a/t/t0001-init.sh +++ b/t/t0001-init.sh @@ -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 && @@ -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 && @@ -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 && @@ -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 && diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh index 987e0c8..3ca275c 100755 --- a/t/t5601-clone.sh +++ b/t/t5601-clone.sh @@ -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 && diff --git a/t/t9130-git-svn-authors-file.sh b/t/t9130-git-svn-authors-file.sh index ec0a106..b324c49 100755 --- a/t/t9130-git-svn-authors-file.sh +++ b/t/t9130-git-svn-authors-file.sh @@ -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 \ diff --git a/t/test-lib.sh b/t/test-lib.sh index 00f23fc..8893406 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -947,9 +947,8 @@ fi GIT_TEMPLATE_DIR="$GIT_BUILD_DIR"/templates/blt unset GIT_CONFIG 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 GIT_ATTR_NOSYSTEM +export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG_NOSYSTEM GIT_ATTR_NOSYSTEM . "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS -- cgit v0.10.2-6-g49f6 From 95a1d12e9b9faddc02187ca28fdeb4fddd354c59 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Tue, 15 Mar 2011 05:10:45 -0500 Subject: tests: scrub environment of GIT_* variables Variables from the inherited environment that are meaningful to git can break tests in undesirable ways. For example, GIT_PAGER=more sh t5400-send-pack.sh -v -i hangs. So unset all environment variables in the GIT_ namespace in test-lib, with a few exceptions: - GIT_TRACE* are useful for tracking down bugs exhibited by a failing test; - GIT_DEBUG* are GIT_TRACE variables by another name, practically speaking. They should probably be tweaked to follow the GIT_TRACE_foo scheme and use trace_printf machinery some time. - GIT_USE_LOOKUP from v1.5.6-rc0~134^2~1 (sha1-lookup: more memory efficient search in sorted list of SHA-1, 2007-12-29) is about trying an alternate implementation strategy rather than changing semantics and it can be useful to compare performance with and without it set. Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano diff --git a/t/test-lib.sh b/t/test-lib.sh index 8893406..8aac727 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -43,29 +43,16 @@ TERM=dumb export LANG LC_ALL PAGER TERM TZ EDITOR=: unset VISUAL -unset GIT_EDITOR 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 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 -- cgit v0.10.2-6-g49f6