Code

Retire support for old environment variables.
authorJunio C Hamano <junkio@cox.net>
Fri, 9 Sep 2005 21:48:54 +0000 (14:48 -0700)
committerJunio C Hamano <junkio@cox.net>
Fri, 9 Sep 2005 21:48:54 +0000 (14:48 -0700)
We have deprecated the old environment variable names for quite a
while and now it's time to remove them.  Gone are:

    SHA1_FILE_DIRECTORIES AUTHOR_DATE AUTHOR_EMAIL AUTHOR_NAME
    COMMIT_AUTHOR_EMAIL COMMIT_AUTHOR_NAME SHA1_FILE_DIRECTORY

Signed-off-by: Junio C Hamano <junkio@cox.net>
13 files changed:
Makefile
cache.h
diff.c
fsck-objects.c
gitenv.c [deleted file]
http-fetch.c
ident.c
init-db.c
path.c
setup.c
sha1_file.c
t/t0100-environment-names.sh [deleted file]
t/t0110-environment-names-old.sh [deleted file]

index c70c9db8f9f74e483e63edd0ea99b186f57692f6..38f705454ea5b3a6badb5b3b1086ed2483db6e21 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -124,7 +124,7 @@ DIFF_OBJS = \
 
 LIB_OBJS = \
        blob.o commit.o connect.o count-delta.o csum-file.o \
-       date.o diff-delta.o entry.o gitenv.o ident.o index.o \
+       date.o diff-delta.o entry.o ident.o index.o \
        object.o pack-check.o patch-delta.o path.o pkt-line.o \
        quote.o read-cache.o refs.o rev-cache.o run-command.o \
        server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \
diff --git a/cache.h b/cache.h
index f0c9b01aa394c0a9a356f4b661141b77a0d7c9f6..dcfcbbc7ce2b50d16ba75b90d99b5eaed59df3c1 100644 (file)
--- a/cache.h
+++ b/cache.h
  */
 #define DEFAULT_GIT_PORT 9418
 
-/*
- * Environment variables transition.
- * We accept older names for now but warn.
- */
-extern char *gitenv_bc(const char *);
-#ifdef __GNUC__
-#define gitenv(e) (getenv(e) ? : gitenv_bc(e))
-#else
-#define gitenv(e) (getenv(e) ? getenv(e) : gitenv_bc(e))
-#endif
-
 /*
  * Basic data structures for the directory cache
  */
diff --git a/diff.c b/diff.c
index 527cbf04adf86fe6fc4c449971ac177d63736330..71696c5eee45af40024a7761f5470f4b3e39b6b9 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -32,10 +32,10 @@ static const char *external_diff(void)
         *
         * GIT_DIFF_OPTS="-c";
         */
-       external_diff_cmd = gitenv("GIT_EXTERNAL_DIFF");
+       external_diff_cmd = getenv("GIT_EXTERNAL_DIFF");
 
        /* In case external diff fails... */
-       env_diff_opts = gitenv("GIT_DIFF_OPTS");
+       env_diff_opts = getenv("GIT_DIFF_OPTS");
        if (env_diff_opts) diff_opts = env_diff_opts;
 
        done_preparing = 1;
index 43d188a139eaf5ea3e5dab100fdd7a284fa722c7..0c5c430ed1f54b981ffb1a3b7a1d73ca24a18561 100644 (file)
@@ -392,7 +392,7 @@ static int fsck_head_link(void)
        static char path[PATH_MAX], link[PATH_MAX];
        const char *git_dir;
 
-       git_dir = gitenv(GIT_DIR_ENVIRONMENT);
+       git_dir = getenv(GIT_DIR_ENVIRONMENT);
        if (!git_dir) git_dir = DEFAULT_GIT_DIR_ENVIRONMENT;
 
        snprintf(path, sizeof(path), "%s/HEAD", git_dir);
diff --git a/gitenv.c b/gitenv.c
deleted file mode 100644 (file)
index ab9396f..0000000
--- a/gitenv.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2005 Junio C Hamano
- */
-#include "cache.h"
-
-/*
- * This array must be sorted by its canonical name, because
- * we do look-up by binary search.
- */
-static struct backward_compatible_env {
-       const char *canonical;
-       const char *old;
-} bc_name[] = {
-       { "GIT_ALTERNATE_OBJECT_DIRECTORIES", "SHA1_FILE_DIRECTORIES" },
-       { "GIT_AUTHOR_DATE", "AUTHOR_DATE" },
-       { "GIT_AUTHOR_EMAIL", "AUTHOR_EMAIL" },
-       { "GIT_AUTHOR_NAME", "AUTHOR_NAME" }, 
-       { "GIT_COMMITTER_EMAIL", "COMMIT_AUTHOR_EMAIL" },
-       { "GIT_COMMITTER_NAME", "COMMIT_AUTHOR_NAME" },
-       { "GIT_OBJECT_DIRECTORY", "SHA1_FILE_DIRECTORY" },
-};
-
-static void warn_old_environment(int pos)
-{
-       int i;
-       static int warned = 0;
-       if (warned)
-               return;
-
-       warned = 1;
-       fprintf(stderr,
-               "warning: Attempting to use %s\n",
-               bc_name[pos].old);
-       fprintf(stderr,
-               "warning: GIT environment variables have been renamed.\n"
-               "warning: Please adjust your scripts and environment.\n");
-       for (i = 0; i < sizeof(bc_name) / sizeof(bc_name[0]); i++) {
-               /* warning is needed only when old name is there and
-                * new name is not.
-                */
-               if (!getenv(bc_name[i].canonical) && getenv(bc_name[i].old))
-                       fprintf(stderr, "warning: old %s => new %s\n",
-                               bc_name[i].old, bc_name[i].canonical);
-       }
-}
-
-char *gitenv_bc(const char *e)
-{
-       int first, last;
-       char *val = getenv(e);
-       if (val)
-               die("gitenv_bc called on existing %s; fix the caller.", e);
-
-       first = 0;
-       last = sizeof(bc_name) / sizeof(bc_name[0]);
-       while (last > first) {
-               int next = (last + first) >> 1;
-               int cmp = strcmp(e, bc_name[next].canonical);
-               if (!cmp) {
-                       val = getenv(bc_name[next].old);
-                       /* If the user has only old name, warn.
-                        * otherwise stay silent.
-                        */
-                       if (val)
-                               warn_old_environment(next);
-                       return val;
-               }
-               if (cmp < 0) {
-                       last = next;
-                       continue;
-               }
-               first = next+1;
-       }
-       return NULL;
-}
index df99ba7cfd4302059e2b7fad6a4373cc47bce8b4..4e564fc4532e0a6665eae9e0586a59cba08c668c 100644 (file)
@@ -355,7 +355,7 @@ int main(int argc, char **argv)
 
        curl = curl_easy_init();
 
-       curl_ssl_verify = gitenv("GIT_SSL_NO_VERIFY") ? 0 : 1;
+       curl_ssl_verify = getenv("GIT_SSL_NO_VERIFY") ? 0 : 1;
        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, curl_ssl_verify);
 #if LIBCURL_VERSION_NUM >= 0x070907
        curl_easy_setopt(curl, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);
diff --git a/ident.c b/ident.c
index 7e917f74de234fd827658805537bc268c34adca6..0df2d979242bd6ee246bd280ffebdf8299408a8c 100644 (file)
--- a/ident.c
+++ b/ident.c
@@ -150,10 +150,10 @@ char *get_ident(const char *name, const char *email, const char *date_str)
 
 char *git_author_info(void)
 {
-       return get_ident(gitenv("GIT_AUTHOR_NAME"), gitenv("GIT_AUTHOR_EMAIL"), gitenv("GIT_AUTHOR_DATE"));
+       return get_ident(getenv("GIT_AUTHOR_NAME"), getenv("GIT_AUTHOR_EMAIL"), getenv("GIT_AUTHOR_DATE"));
 }
 
 char *git_committer_info(void)
 {
-       return get_ident(gitenv("GIT_COMMITTER_NAME"), gitenv("GIT_COMMITTER_EMAIL"), gitenv("GIT_COMMITTER_DATE"));
+       return get_ident(getenv("GIT_COMMITTER_NAME"), getenv("GIT_COMMITTER_EMAIL"), getenv("GIT_COMMITTER_DATE"));
 }
index 50b16b34b0e3a3fe4de29252eb9261055913e262..902bdfaafb53e15382c901936a1ccd2fec90f0f3 100644 (file)
--- a/init-db.c
+++ b/init-db.c
@@ -226,7 +226,7 @@ int main(int argc, char **argv)
        /*
         * Set up the default .git directory contents
         */
-       git_dir = gitenv(GIT_DIR_ENVIRONMENT);
+       git_dir = getenv(GIT_DIR_ENVIRONMENT);
        if (!git_dir) {
                git_dir = DEFAULT_GIT_DIR_ENVIRONMENT;
                fprintf(stderr, "defaulting to local storage area\n");
diff --git a/path.c b/path.c
index 142e575e5c293b92ff8a5612c7acc86d050c1119..f788028a63dbd9b34563d2589697f4b5d65b8648 100644 (file)
--- a/path.c
+++ b/path.c
@@ -45,7 +45,7 @@ char *git_path(const char *fmt, ...)
        va_list args;
        unsigned len;
 
-       git_dir = gitenv(GIT_DIR_ENVIRONMENT);
+       git_dir = getenv(GIT_DIR_ENVIRONMENT);
        if (!git_dir) git_dir = DEFAULT_GIT_DIR_ENVIRONMENT;
        len = strlen(git_dir);
        if (len > PATH_MAX-100)
diff --git a/setup.c b/setup.c
index 258da176150081749a2ca2faeebc316911f0fba1..3973668f017e209e714950f4175d26f8a409cce3 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -87,7 +87,7 @@ static int is_toplevel_directory(void)
        return  !lstat(".git/HEAD", &st) &&
                S_ISLNK(st.st_mode) &&
                !access(".git/refs/", X_OK) &&
-               (gitenv(DB_ENVIRONMENT) || !access(".git/objects/", X_OK));
+               (getenv(DB_ENVIRONMENT) || !access(".git/objects/", X_OK));
 }
 
 const char *setup_git_directory(void)
@@ -99,7 +99,7 @@ const char *setup_git_directory(void)
         * If GIT_DIR is set explicitly, we're not going
         * to do any discovery
         */
-       if (gitenv(GIT_DIR_ENVIRONMENT))
+       if (getenv(GIT_DIR_ENVIRONMENT))
                return NULL;
 
        if (!getcwd(cwd, sizeof(cwd)) || cwd[0] != '/')
index 64eac592bbf191b2c97ccf8739fdb0d4712d7788..f4c742eed4736e121448eb8d24697aa812a0d158 100644 (file)
@@ -50,22 +50,22 @@ static char *git_dir, *git_object_dir, *git_index_file, *git_refs_dir,
        *git_graft_file;
 static void setup_git_env(void)
 {
-       git_dir = gitenv(GIT_DIR_ENVIRONMENT);
+       git_dir = getenv(GIT_DIR_ENVIRONMENT);
        if (!git_dir)
                git_dir = DEFAULT_GIT_DIR_ENVIRONMENT;
-       git_object_dir = gitenv(DB_ENVIRONMENT);
+       git_object_dir = getenv(DB_ENVIRONMENT);
        if (!git_object_dir) {
                git_object_dir = xmalloc(strlen(git_dir) + 9);
                sprintf(git_object_dir, "%s/objects", git_dir);
        }
        git_refs_dir = xmalloc(strlen(git_dir) + 6);
        sprintf(git_refs_dir, "%s/refs", git_dir);
-       git_index_file = gitenv(INDEX_ENVIRONMENT);
+       git_index_file = getenv(INDEX_ENVIRONMENT);
        if (!git_index_file) {
                git_index_file = xmalloc(strlen(git_dir) + 7);
                sprintf(git_index_file, "%s/index", git_dir);
        }
-       git_graft_file = gitenv(GRAFT_ENVIRONMENT);
+       git_graft_file = getenv(GRAFT_ENVIRONMENT);
        if (!git_graft_file)
                git_graft_file = strdup(git_path("info/grafts"));
 }
@@ -285,7 +285,7 @@ void prepare_alt_odb(void)
        struct stat st;
        char *alt;
 
-       alt = gitenv(ALTERNATE_DB_ENVIRONMENT);
+       alt = getenv(ALTERNATE_DB_ENVIRONMENT);
        if (!alt) alt = "";
 
        sprintf(path, "%s/info/alternates", get_object_directory());
diff --git a/t/t0100-environment-names.sh b/t/t0100-environment-names.sh
deleted file mode 100755 (executable)
index 3493bd4..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2005 Junio C Hamano
-#
-
-test_description='general environment name warning test.
-
-This test makes sure that use of deprecated environment variables
-trigger the warnings from gitenv().'
-
-env_vars='GIT_AUTHOR_DATE:AUTHOR_DATE
-GIT_AUTHOR_EMAIL:AUTHOR_EMAIL
-GIT_AUTHOR_NAME:AUTHOR_NAME
-GIT_COMMITTER_EMAIL:COMMIT_AUTHOR_EMAIL
-GIT_COMMITTER_NAME:COMMIT_AUTHOR_NAME
-GIT_ALTERNATE_OBJECT_DIRECTORIES:SHA1_FILE_DIRECTORIES
-GIT_OBJECT_DIRECTORY:SHA1_FILE_DIRECTORY
-'
-
-. ./test-lib.sh
-
-export_them () {
-       for ev in $env_vars
-       do
-               new=$(expr "$ev" : '\(.*\):')
-               old=$(expr "$ev" : '.*:\(.*\)')
-               # Build and eval the following:
-               # case "${VAR+set}" in set) export VAR;; esac
-               evstr='case "${'$new'+set}" in set) export '$new';; esac'
-               eval "$evstr"
-               evstr='case "${'$old'+set}" in set) export '$old';; esac'
-               eval "$evstr"
-       done
-}
-
-date >path0
-git-update-index --add path0
-tree=$(git-write-tree)
-
-AUTHOR_DATE='Wed May 11 23:55:18 2005'
-AUTHOR_EMAIL='author@example.xz'
-AUTHOR_NAME='A U Thor'
-COMMIT_AUTHOR_EMAIL='author@example.xz'
-COMMIT_AUTHOR_NAME='A U Thor'
-SHA1_FILE_DIRECTORY=.git/objects
-
-export_them
-
-echo 'foo' | git-commit-tree $tree >/dev/null 2>errmsg
-cat >expected-err <<\EOF
-warning: Attempting to use SHA1_FILE_DIRECTORY
-warning: GIT environment variables have been renamed.
-warning: Please adjust your scripts and environment.
-warning: old AUTHOR_DATE => new GIT_AUTHOR_DATE
-warning: old AUTHOR_EMAIL => new GIT_AUTHOR_EMAIL
-warning: old AUTHOR_NAME => new GIT_AUTHOR_NAME
-warning: old COMMIT_AUTHOR_EMAIL => new GIT_COMMITTER_EMAIL
-warning: old COMMIT_AUTHOR_NAME => new GIT_COMMITTER_NAME
-warning: old SHA1_FILE_DIRECTORY => new GIT_OBJECT_DIRECTORY
-EOF
-sed -ne '/^warning: /p' <errmsg >generated-err
-
-test_expect_success \
-    'using old names should issue warnings.' \
-    'cmp generated-err expected-err'
-
-for ev in $env_vars
-do
-       new=$(expr "$ev" : '\(.*\):')
-       old=$(expr "$ev" : '.*:\(.*\)')
-       # Build and eval the following:
-       # NEWENV=$OLDENV
-       evstr="$new=\$$old"
-       eval "$evstr"
-done
-export_them
-echo 'foo' | git-commit-tree $tree >/dev/null 2>errmsg
-sed -ne '/^warning: /p' <errmsg >generated-err
-
-test_expect_success \
-    'using old names but having new names should not issue warnings.' \
-    'cmp generated-err /dev/null'
-
-test_done
diff --git a/t/t0110-environment-names-old.sh b/t/t0110-environment-names-old.sh
deleted file mode 100755 (executable)
index 5d602cc..0000000
+++ /dev/null
@@ -1,132 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2005 Junio C Hamano
-#
-
-test_description='Using new and old environment names.
-
-This test makes sure that use of deprecated environment variables
-still works, using both new and old names makes new one take precedence,
-and GIT_DIR and GIT_ALTERNATE_OBJECT_DIRECTORIES mechanism works.'
-
-env_vars='GIT_AUTHOR_DATE:AUTHOR_DATE
-GIT_AUTHOR_EMAIL:AUTHOR_EMAIL
-GIT_AUTHOR_NAME:AUTHOR_NAME
-GIT_COMMITTER_EMAIL:COMMIT_AUTHOR_EMAIL
-GIT_COMMITTER_NAME:COMMIT_AUTHOR_NAME
-GIT_ALTERNATE_OBJECT_DIRECTORIES:SHA1_FILE_DIRECTORIES
-GIT_OBJECT_DIRECTORY:SHA1_FILE_DIRECTORY
-'
-
-. ./test-lib.sh
-
-export_them () {
-       for ev in $env_vars
-       do
-               new=$(expr "$ev" : '\(.*\):')
-               old=$(expr "$ev" : '.*:\(.*\)')
-               # Build and eval the following:
-               # case "${VAR+set}" in set) export VAR;; esac
-               evstr='case "${'$new'+set}" in set) export '$new';; esac'
-               eval "$evstr"
-               evstr='case "${'$old'+set}" in set) export '$old';; esac'
-               eval "$evstr"
-       done
-}
-
-SHA1_FILE_DIRECTORY=.svn/objects ;# whoa
-export SHA1_FILE_DIRECTORY
-
-rm -fr .git
-mkdir .svn
-test_expect_success \
-    'using SHA1_FILE_DIRECTORY in git-init-db' \
-    'git-init-db && test -d .svn/objects/cb'
-
-unset SHA1_FILE_DIRECTORY
-GIT_DIR=.svn
-export GIT_DIR
-rm -fr .git .svn
-mkdir .svn
-test_expect_success \
-    'using GIT_DIR in git-init-db' \
-    'git-init-db && test -d .svn/objects/cb'
-
-date >path0
-test_expect_success \
-    'using GIT_DIR in git-update-index' \
-    'git-update-index --add path0 && test -f .svn/index'
-
-sedScript='s|\(..\)|.svn/objects/\1/|'
-
-test_expect_success \
-    'using GIT_DIR in git-write-tree' \
-    'tree=$(git-write-tree) &&
-     test -f $(echo "$tree" | sed -e "$sedScript")'
-
-AUTHOR_DATE='Sat May 14 00:00:00 2005 -0000'
-AUTHOR_EMAIL='author@example.xz'
-AUTHOR_NAME='A U Thor'
-COMMIT_AUTHOR_EMAIL='author@example.xz'
-COMMIT_AUTHOR_NAME='A U Thor'
-export_them
-
-test_expect_success \
-    'using GIT_DIR and old variable names in git-commit-tree' \
-    'commit=$(echo foo | git-commit-tree $tree) &&
-     test -f $(echo "$commit" | sed -e "$sedScript")'
-
-test_expect_success \
-    'using GIT_DIR in git-cat-file' \
-    'git-cat-file commit $commit >current'
-
-cat >expected <<\EOF
-author A U Thor <author@example.xz>
-committer A U Thor <author@example.xz>
-EOF
-test_expect_success \
-    'verify old AUTHOR variables were used correctly in commit' \
-    'sed -ne '\''/^\(author\)/s|>.*|>|p'\'' -e'\''/^\(committer\)/s|>.*|>|p'\''\    current > out && cmp out expected'
-
-unset GIT_DIR
-test_expect_success \
-    'git-init-db without GIT_DIR' \
-    'git-init-db && test -d .git && test -d .git/objects/ef'
-
-SHA1_FILE_DIRECTORIES=.svn/objects
-export SHA1_FILE_DIRECTORIES
-
-test_expect_success \
-    'using SHA1_FILE_DIRECTORIES with git-ls-tree' \
-    'git-ls-tree $commit && git-ls-tree $tree'
-
-GIT_AUTHOR_DATE='Sat May 14 12:00:00 2005 -0000'
-GIT_AUTHOR_EMAIL='rohtua@example.xz'
-GIT_AUTHOR_NAME='R O Htua'
-GIT_COMMITTER_EMAIL='rohtua@example.xz'
-GIT_COMMITTER_NAME='R O Htua'
-export_them
-
-sedScript='s|\(..\)|.git/objects/\1/|'
-test_expect_success \
-    'using new author variables with git-commit-tree' \
-    'commit2=$(echo foo | git-commit-tree $tree) &&
-     test -f $(echo "$commit2" | sed -e "$sedScript")'
-
-GIT_ALTERNATE_OBJECT_DIRECTORIES=.git/objects
-GIT_DIR=nowhere
-export GIT_DIR GIT_ALTERNATE_OBJECT_DIRECTORIES
-
-test_expect_success \
-    'git-cat-file with GIT_DIR and GIT_ALTERNATE_OBJECT_DIRECTORIES' \
-    'git-cat-file commit $commit2 >current'
-
-cat >expected <<\EOF
-author R O Htua <rohtua@example.xz>
-committer R O Htua <rohtua@example.xz>
-EOF
-test_expect_success \
-    'verify new AUTHOR variables were used correctly in commit.' \
-    'sed -ne '\''/^\(author\)/s|>.*|>|p'\'' -e'\''/^\(committer\)/s|>.*|>|p'\''\    current > out && cmp out expected'
-
-test_done