Code

Update public documentation links for 1.5.2.3
[git.git] / setup.c
diff --git a/setup.c b/setup.c
index 7e32de229dbbbabb812479cb42862bc111578b32..01f74d4644c35862b2498ee8534213b2d76bf721 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -39,7 +39,7 @@ const char *prefix_path(const char *prefix, int len, const char *path)
        if (len) {
                int speclen = strlen(path);
                char *n = xmalloc(speclen + len + 1);
-       
+
                memcpy(n, prefix, len);
                memcpy(n + len, path, speclen+1);
                path = n;
@@ -47,7 +47,7 @@ const char *prefix_path(const char *prefix, int len, const char *path)
        return path;
 }
 
-/* 
+/*
  * Unlike prefix_path, this should be used if the named file does
  * not have to interact with index entry; i.e. name of a random file
  * on the filesystem.
@@ -95,7 +95,7 @@ void verify_non_filename(const char *prefix, const char *arg)
        const char *name;
        struct stat st;
 
-       if (is_inside_git_dir())
+       if (!is_inside_work_tree() || is_inside_git_dir())
                return;
        if (*arg == '-')
                return; /* flag */
@@ -251,6 +251,9 @@ const char *setup_git_directory_gently(int *nongit_ok)
                        die("Not a git repository");
                }
                setenv(GIT_DIR_ENVIRONMENT, cwd, 1);
+               gitdirenv = getenv(GIT_DIR_ENVIRONMENT);
+               if (!gitdirenv)
+                       die("getenv after setenv failed");
        }
 
        if (PATH_MAX - 40 < strlen(gitdirenv)) {
@@ -290,6 +293,8 @@ const char *setup_git_directory_gently(int *nongit_ok)
        if (gitdirenv[0] != '/') {
                setenv(GIT_DIR_ENVIRONMENT, gitdir, 1);
                gitdirenv = getenv(GIT_DIR_ENVIRONMENT);
+               if (!gitdirenv)
+                       die("getenv after setenv failed");
                if (PATH_MAX - 40 < strlen(gitdirenv)) {
                        if (nongit_ok) {
                                *nongit_ok = 1;