{"thread":{"id":"8760","subject":"[PATCH] getenv/setenv: use constants if available","startedAt":"2007-06-28T14:15:25Z","lastAt":"2007-06-28T14:15:25Z","messageCount":1,"participants":["Matthias Lederhofer"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"45980","messageId":"20070628141525.GA25448@moooo.ath.cx","threadId":"8760","inReplyTo":null,"subject":"[PATCH] getenv/setenv: use constants if available","fromName":"Matthias Lederhofer","fromEmail":"matled@gmx.net","sentAt":"2007-06-28T14:15:25Z","receivedAt":"2007-06-28T14:15:25Z","isPatch":true,"sender":{"key":"matled@gmx.net","avatar":null},"body":"There were places using \"GIT_DIR\" instead of GIT_DIR_ENVIRONMENT and\n\"GIT_CONFIG\" instead of CONFIG_ENVIRONMENT.  This makes it easier to\nfind all places touching an environment variable using git grep or\nsimilar tools.\n\nSigned-off-by: Matthias Lederhofer <matled@gmx.net>\n---\nI only found one other place where a string was used directly even\nthough there is a constant: GIT_REFLOG_ACTION is only defined in\ngit-revert.c and builtin-fetch--tool.c uses the environment variable\ntoo.  At least when searching with grep this makes no problem because\nthe name of the constant is the same as the string it is defined to..\n---\n builtin-config.c |    4 ++--\n path.c           |    2 +-\n 2 files changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin-config.c b/builtin-config.c\nindex 3f7cab1..7d2063c 100644\n--- a/builtin-config.c\n+++ b/builtin-config.c\n@@ -178,14 +178,14 @@ int cmd_config(int argc, const char **argv, const char *prefix)\n \t\t\tchar *home = getenv(\"HOME\");\n \t\t\tif (home) {\n \t\t\t\tchar *user_config = xstrdup(mkpath(\"%s/.gitconfig\", home));\n-\t\t\t\tsetenv(\"GIT_CONFIG\", user_config, 1);\n+\t\t\t\tsetenv(CONFIG_ENVIRONMENT, user_config, 1);\n \t\t\t\tfree(user_config);\n \t\t\t} else {\n \t\t\t\tdie(\"$HOME not set\");\n \t\t\t}\n \t\t}\n \t\telse if (!strcmp(argv[1], \"--system\"))\n-\t\t\tsetenv(\"GIT_CONFIG\", ETC_GITCONFIG, 1);\n+\t\t\tsetenv(CONFIG_ENVIRONMENT, ETC_GITCONFIG, 1);\n \t\telse if (!strcmp(argv[1], \"--null\") || !strcmp(argv[1], \"-z\")) {\n \t\t\tterm = '\\0';\n \t\t\tdelim = '\\n';\ndiff --git a/path.c b/path.c\nindex 6395cf2..c4ce962 100644\n--- a/path.c\n+++ b/path.c\n@@ -252,7 +252,7 @@ char *enter_repo(char *path, int strict)\n \n \tif (access(\"objects\", X_OK) == 0 && access(\"refs\", X_OK) == 0 &&\n \t    validate_headref(\"HEAD\") == 0) {\n-\t\tsetenv(\"GIT_DIR\", \".\", 1);\n+\t\tsetenv(GIT_DIR_ENVIRONMENT, \".\", 1);\n \t\tcheck_repository_format();\n \t\treturn path;\n \t}\n-- \n1.5.2.2.1398.ga4b05\n"}]}