2 * Copyright (C) 2005 Junio C Hamano
7 * This array must be sorted by its canonical name, because
8 * we do look-up by binary search.
10 static struct backward_compatible_env {
11 const char *canonical;
14 { "GIT_ALTERNATE_OBJECT_DIRECTORIES", "SHA1_FILE_DIRECTORIES" },
15 { "GIT_AUTHOR_DATE", "AUTHOR_DATE" },
16 { "GIT_AUTHOR_EMAIL", "AUTHOR_EMAIL" },
17 { "GIT_AUTHOR_NAME", "AUTHOR_NAME" },
18 { "GIT_COMMITTER_EMAIL", "COMMIT_AUTHOR_EMAIL" },
19 { "GIT_COMMITTER_NAME", "COMMIT_AUTHOR_NAME" },
20 { "GIT_OBJECT_DIRECTORY", "SHA1_FILE_DIRECTORY" },
23 static void warn_old_environment(int pos)
26 static int warned = 0;
32 "warning: Attempting to use %s\n",
35 "warning: GIT environment variables have been renamed.\n"
36 "warning: Please adjust your scripts and environment.\n");
37 for (i = 0; i < sizeof(bc_name) / sizeof(bc_name[0]); i++) {
38 /* warning is needed only when old name is there and
41 if (!getenv(bc_name[i].canonical) && getenv(bc_name[i].old))
42 fprintf(stderr, "warning: old %s => new %s\n",
43 bc_name[i].old, bc_name[i].canonical);
47 char *gitenv_bc(const char *e)
50 char *val = getenv(e);
52 die("gitenv_bc called on existing %s; fix the caller.", e);
55 last = sizeof(bc_name) / sizeof(bc_name[0]);
56 while (last > first) {
57 int next = (last + first) >> 1;
58 int cmp = strcmp(e, bc_name[next].canonical);
60 val = getenv(bc_name[next].old);
61 /* If the user has only old name, warn.
62 * otherwise stay silent.
65 warn_old_environment(next);