use xgetcwd() to set $GIT_DIR
[gitweb.git] / git.c
diff --git a/git.c b/git.c
index 9efd1a3ec1f2af63fe575f9c755dff685d9b1e51..c4e8c5cfdfadac8eb19a977854cf79cf2bce3881 100644 (file)
--- a/git.c
+++ b/git.c
@@ -125,9 +125,10 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
                        if (envchanged)
                                *envchanged = 1;
                } else if (!strcmp(cmd, "--bare")) {
-                       static char git_dir[PATH_MAX+1];
+                       char *cwd = xgetcwd();
                        is_bare_repository_cfg = 1;
-                       setenv(GIT_DIR_ENVIRONMENT, getcwd(git_dir, sizeof(git_dir)), 0);
+                       setenv(GIT_DIR_ENVIRONMENT, cwd, 0);
+                       free(cwd);
                        setenv(GIT_IMPLICIT_WORK_TREE_ENVIRONMENT, "0", 1);
                        if (envchanged)
                                *envchanged = 1;