]> asedeno.scripts.mit.edu Git - git.git/blobdiff - setup.c
Merge branch 'jc/refuse-push-to-current'
[git.git] / setup.c
diff --git a/setup.c b/setup.c
index 833ced2269ae45b08f381fb2644b74f47cf50d1a..dfda532adc16f5e6d25d7cfc5add3e0e2b6a5209 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -456,7 +456,11 @@ const char *setup_git_directory_gently(int *nongit_ok)
                        inside_git_dir = 1;
                        if (!work_tree_env)
                                inside_work_tree = 0;
-                       setenv(GIT_DIR_ENVIRONMENT, ".", 1);
+                       if (offset != len) {
+                               cwd[offset] = '\0';
+                               setenv(GIT_DIR_ENVIRONMENT, cwd, 1);
+                       } else
+                               setenv(GIT_DIR_ENVIRONMENT, ".", 1);
                        check_repository_format_gently(nongit_ok);
                        return NULL;
                }
@@ -468,7 +472,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
                                *nongit_ok = 1;
                                return NULL;
                        }
-                       die("Not a git repository");
+                       die("Not a git repository (or any of the parent directories): %s", DEFAULT_GIT_DIR_ENVIRONMENT);
                }
                if (chdir(".."))
                        die("Cannot change to %s/..: %s", cwd, strerror(errno));