git.c: make it clear save_env() is for alias handling only
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Thu, 3 Dec 2015 18:17:55 +0000 (19:17 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 22 Dec 2015 21:40:32 +0000 (13:40 -0800)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git.c
diff --git a/git.c b/git.c
index fe94066aeebb0d71ea140c3d67ac4ad232db0799..99c4327c88d1d1201cc79cbd59615e92037e011f 100644 (file)
--- a/git.c
+++ b/git.c
@@ -25,14 +25,14 @@ static const char *env_names[] = {
        GIT_PREFIX_ENVIRONMENT
 };
 static char *orig_env[4];
-static int saved_environment;
+static int saved_env_before_alias;
 
-static void save_env(void)
+static void save_env_before_alias(void)
 {
        int i;
-       if (saved_environment)
+       if (saved_env_before_alias)
                return;
-       saved_environment = 1;
+       saved_env_before_alias = 1;
        orig_cwd = xgetcwd();
        for (i = 0; i < ARRAY_SIZE(env_names); i++) {
                orig_env[i] = getenv(env_names[i]);
@@ -233,6 +233,7 @@ static int handle_alias(int *argcp, const char ***argv)
        char *alias_string;
        int unused_nongit;
 
+       save_env_before_alias();
        subdir = setup_git_directory_gently(&unused_nongit);
 
        alias_command = (*argv)[0];
@@ -527,7 +528,7 @@ static void handle_builtin(int argc, const char **argv)
 
        builtin = get_builtin(cmd);
        if (builtin) {
-               if (saved_environment && (builtin->option & NO_SETUP))
+               if (saved_env_before_alias && (builtin->option & NO_SETUP))
                        restore_env();
                else
                        exit(run_builtin(builtin, argc, argv));
@@ -587,7 +588,6 @@ static int run_argv(int *argcp, const char ***argv)
                 */
                if (done_alias)
                        break;
-               save_env();
                if (!handle_alias(argcp, argv))
                        break;
                done_alias = 1;