diff options
Diffstat (limited to 'setup.c')
-rw-r--r-- | setup.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -370,7 +370,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; } @@ -382,9 +386,10 @@ 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); } - chdir(".."); + if (chdir("..")) + die("Cannot change to %s/..: %s", cwd, strerror(errno)); } inside_git_dir = 0; |