aboutsummaryrefslogtreecommitdiff
path: root/environment.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-03-30 14:07:13 -0700
committerJunio C Hamano <gitster@pobox.com>2017-03-30 14:07:13 -0700
commit7a09a61e66e34d936c2cc628170031a754ce6e5f (patch)
treecf7dd2ed1609b671514205e343cceaf008942fa6 /environment.c
parent1fdbfc443e9ef702df9a305231e15f020920c87a (diff)
parentb1ef400eece473f83f39980c54f67e3e7d202538 (diff)
downloadgit-7a09a61e66e34d936c2cc628170031a754ce6e5f.tar.gz
git-7a09a61e66e34d936c2cc628170031a754ce6e5f.tar.xz
Merge branch 'jk/no-looking-at-dotgit-outside-repo-final'
This is the endgame of the topic to avoid blindly falling back to ".git" when the setup sequence said we are _not_ in Git repository. A corner case that happens to work right now may be broken by a call to die("BUG"). * jk/no-looking-at-dotgit-outside-repo-final: setup_git_env: avoid blind fall-back to ".git"
Diffstat (limited to 'environment.c')
-rw-r--r--environment.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/environment.c b/environment.c
index 2fdba7622..a17d96aa8 100644
--- a/environment.c
+++ b/environment.c
@@ -167,8 +167,11 @@ static void setup_git_env(void)
const char *replace_ref_base;
git_dir = getenv(GIT_DIR_ENVIRONMENT);
- if (!git_dir)
+ if (!git_dir) {
+ if (!startup_info->have_repository)
+ die("BUG: setup_git_env called without repository");
git_dir = DEFAULT_GIT_DIR_ENVIRONMENT;
+ }
gitfile = read_gitfile(git_dir);
git_dir = xstrdup(gitfile ? gitfile : git_dir);
if (get_common_dir(&sb, git_dir))