Skip to content

Commit 50aaeca

Browse files
committed
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
2 parents f59bf09 + 95a1d12 commit 50aaeca

File tree

8 files changed

+11
-47
lines changed

8 files changed

+11
-47
lines changed

attr.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -478,11 +478,6 @@ int git_attr_system(void)
478478
return !git_env_bool("GIT_ATTR_NOSYSTEM", 0);
479479
}
480480

481-
int git_attr_global(void)
482-
{
483-
return !git_env_bool("GIT_ATTR_NOGLOBAL", 0);
484-
}
485-
486481
static int git_attr_config(const char *var, const char *value, void *dummy)
487482
{
488483
if (!strcmp(var, "core.attributesfile"))
@@ -511,7 +506,7 @@ static void bootstrap_attr_stack(void)
511506
}
512507

513508
git_config(git_attr_config, NULL);
514-
if (git_attr_global() && attributes_file) {
509+
if (attributes_file) {
515510
elem = read_attr_from_file(attributes_file, 1);
516511
if (elem) {
517512
elem->origin = NULL;

builtin/config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ static int get_value(const char *key_, const char *regex_)
160160
if (!local) {
161161
const char *home = getenv("HOME");
162162
local = repo_config = git_pathdup("config");
163-
if (git_config_global() && home)
163+
if (home)
164164
global = xstrdup(mkpath("%s/.gitconfig", home));
165165
if (git_config_system())
166166
system_wide = git_etc_gitconfig();

cache.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,6 @@ extern const char *git_etc_gitconfig(void);
10221022
extern int check_repository_format_version(const char *var, const char *value, void *cb);
10231023
extern int git_env_bool(const char *, int);
10241024
extern int git_config_system(void);
1025-
extern int git_config_global(void);
10261025
extern int config_error_nonbool(const char *);
10271026
extern const char *get_log_output_encoding(void);
10281027
extern const char *get_commit_output_encoding(void);

config.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -825,11 +825,6 @@ int git_config_system(void)
825825
return !git_env_bool("GIT_CONFIG_NOSYSTEM", 0);
826826
}
827827

828-
int git_config_global(void)
829-
{
830-
return !git_env_bool("GIT_CONFIG_NOGLOBAL", 0);
831-
}
832-
833828
int git_config_from_parameters(config_fn_t fn, void *data)
834829
{
835830
static int loaded_environment;
@@ -861,7 +856,7 @@ int git_config_early(config_fn_t fn, void *data, const char *repo_config)
861856
}
862857

863858
home = getenv("HOME");
864-
if (git_config_global() && home) {
859+
if (home) {
865860
char *user_config = xstrdup(mkpath("%s/.gitconfig", home));
866861
if (!access(user_config, R_OK)) {
867862
ret += git_config_from_file(fn, user_config, data);

t/t0001-init.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ test_expect_success 'plain nested in bare' '
4747

4848
test_expect_success 'plain through aliased command, outside any git repo' '
4949
(
50-
sane_unset GIT_DIR GIT_WORK_TREE GIT_CONFIG_NOGLOBAL &&
50+
sane_unset GIT_DIR GIT_WORK_TREE &&
5151
HOME=$(pwd)/alias-config &&
5252
export HOME &&
5353
mkdir alias-config &&
@@ -231,7 +231,6 @@ test_expect_success 'init with init.templatedir set' '
231231
git config -f "$test_config" init.templatedir "${HOME}/templatedir-source" &&
232232
mkdir templatedir-set &&
233233
cd templatedir-set &&
234-
sane_unset GIT_CONFIG_NOGLOBAL &&
235234
sane_unset GIT_TEMPLATE_DIR &&
236235
NO_SET_GIT_TEMPLATE_DIR=t &&
237236
export NO_SET_GIT_TEMPLATE_DIR &&
@@ -243,7 +242,6 @@ test_expect_success 'init with init.templatedir set' '
243242
test_expect_success 'init --bare/--shared overrides system/global config' '
244243
(
245244
test_config="$HOME"/.gitconfig &&
246-
sane_unset GIT_CONFIG_NOGLOBAL &&
247245
git config -f "$test_config" core.bare false &&
248246
git config -f "$test_config" core.sharedRepository 0640 &&
249247
mkdir init-bare-shared-override &&
@@ -258,7 +256,6 @@ test_expect_success 'init --bare/--shared overrides system/global config' '
258256
test_expect_success 'init honors global core.sharedRepository' '
259257
(
260258
test_config="$HOME"/.gitconfig &&
261-
sane_unset GIT_CONFIG_NOGLOBAL &&
262259
git config -f "$test_config" core.sharedRepository 0666 &&
263260
mkdir shared-honor-global &&
264261
cd shared-honor-global &&

t/t5601-clone.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ test_expect_success 'clone a void' '
164164
test_expect_success 'clone respects global branch.autosetuprebase' '
165165
(
166166
test_config="$HOME/.gitconfig" &&
167-
unset GIT_CONFIG_NOGLOBAL &&
168167
git config -f "$test_config" branch.autosetuprebase remote &&
169168
rm -fr dst &&
170169
git clone src dst &&

t/t9130-git-svn-authors-file.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ test_expect_success 'fresh clone with svn.authors-file in config' '
9696
rm -r "$GIT_DIR" &&
9797
test x = x"$(git config svn.authorsfile)" &&
9898
test_config="$HOME"/.gitconfig &&
99-
unset GIT_CONFIG_NOGLOBAL &&
10099
unset GIT_DIR &&
101100
unset GIT_CONFIG &&
102101
git config --global \

t/test-lib.sh

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -43,36 +43,16 @@ TERM=dumb
4343
export LANG LC_ALL PAGER TERM TZ
4444
EDITOR=:
4545
unset VISUAL
46-
unset GIT_EDITOR
47-
unset AUTHOR_DATE
48-
unset AUTHOR_EMAIL
49-
unset AUTHOR_NAME
50-
unset COMMIT_AUTHOR_EMAIL
51-
unset COMMIT_AUTHOR_NAME
5246
unset EMAIL
53-
unset GIT_ALTERNATE_OBJECT_DIRECTORIES
54-
unset GIT_AUTHOR_DATE
47+
unset $(perl -e '
48+
my @env = keys %ENV;
49+
my @vars = grep(/^GIT_/ && !/^GIT_(TRACE|DEBUG|USE_LOOKUP)/, @env);
50+
print join("\n", @vars);
51+
')
5552
GIT_AUTHOR_EMAIL=author@example.com
5653
GIT_AUTHOR_NAME='A U Thor'
57-
unset GIT_COMMITTER_DATE
5854
GIT_COMMITTER_EMAIL=committer@example.com
5955
GIT_COMMITTER_NAME='C O Mitter'
60-
unset GIT_DIFF_OPTS
61-
unset GIT_DIR
62-
unset GIT_WORK_TREE
63-
unset GIT_EXTERNAL_DIFF
64-
unset GIT_INDEX_FILE
65-
unset GIT_OBJECT_DIRECTORY
66-
unset GIT_CEILING_DIRECTORIES
67-
unset SHA1_FILE_DIRECTORIES
68-
unset SHA1_FILE_DIRECTORY
69-
unset GIT_NOTES_REF
70-
unset GIT_NOTES_DISPLAY_REF
71-
unset GIT_NOTES_REWRITE_REF
72-
unset GIT_NOTES_REWRITE_MODE
73-
unset GIT_REFLOG_ACTION
74-
unset GIT_CHERRY_PICK_HELP
75-
unset GIT_QUIET
7656
GIT_MERGE_VERBOSITY=5
7757
export GIT_MERGE_VERBOSITY
7858
export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME
@@ -954,8 +934,8 @@ fi
954934
GIT_TEMPLATE_DIR="$GIT_BUILD_DIR"/templates/blt
955935
unset GIT_CONFIG
956936
GIT_CONFIG_NOSYSTEM=1
957-
GIT_CONFIG_NOGLOBAL=1
958-
export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG_NOSYSTEM GIT_CONFIG_NOGLOBAL
937+
GIT_ATTR_NOSYSTEM=1
938+
export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG_NOSYSTEM GIT_ATTR_NOSYSTEM
959939

960940
. "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS
961941

0 commit comments

Comments
 (0)