Code

setenv(GIT_DIR) clean-up
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>
Sat, 6 Feb 2010 09:35:19 +0000 (10:35 +0100)
committerJunio C Hamano <gitster@pobox.com>
Sat, 6 Feb 2010 18:39:20 +0000 (10:39 -0800)
This patch converts the setenv() calls in path.c and setup.c.  After
the call, git grep with a pager works again in bare repos.

It leaves the setenv(GIT_DIR_ENVIRONMENT, ...) calls in git.c alone, as
they respond to command line switches that emulate the effect of setting
the environment variable directly.

The remaining site in environment.c is in set_git_dir() and is left
alone, too, of course.  Finally, builtin-init-db.c is left changed
because the repo is still being carefully constructed when the
environment variable is set.

This fixes git shortlog when run inside a git directory, which had been
broken by abe549e1.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
path.c
setup.c

diff --git a/path.c b/path.c
index 79aa104712364a8c18964feecd4c8079449a78cf..0005df3a5faad038b1d3af07585faaf1e8d59de4 100644 (file)
--- a/path.c
+++ b/path.c
@@ -336,7 +336,7 @@ char *enter_repo(char *path, int strict)
 
        if (access("objects", X_OK) == 0 && access("refs", X_OK) == 0 &&
            validate_headref("HEAD") == 0) {
-               setenv(GIT_DIR_ENVIRONMENT, ".", 1);
+               set_git_dir(".");
                check_repository_format();
                return path;
        }
diff --git a/setup.c b/setup.c
index 710e2f3008c79c08cdc507288881c9a58311283a..b38cbee145e8f3aa13d79cd80640841ec2fb350e 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -404,9 +404,9 @@ const char *setup_git_directory_gently(int *nongit_ok)
                                inside_work_tree = 0;
                        if (offset != len) {
                                cwd[offset] = '\0';
-                               setenv(GIT_DIR_ENVIRONMENT, cwd, 1);
+                               set_git_dir(cwd);
                        } else
-                               setenv(GIT_DIR_ENVIRONMENT, ".", 1);
+                               set_git_dir(".");
                        check_repository_format_gently(nongit_ok);
                        return NULL;
                }