diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-03-30 14:07:13 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-03-30 14:07:13 -0700 |
commit | 7a09a61e66e34d936c2cc628170031a754ce6e5f (patch) | |
tree | cf7dd2ed1609b671514205e343cceaf008942fa6 /environment.c | |
parent | 1fdbfc443e9ef702df9a305231e15f020920c87a (diff) | |
parent | b1ef400eece473f83f39980c54f67e3e7d202538 (diff) | |
download | git-7a09a61e66e34d936c2cc628170031a754ce6e5f.tar.gz |
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.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/environment.c b/environment.c index 2fdba76222..a17d96aa85 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)) |