environment: place key repository state in the_repository

Migrate 'git_dir', 'git_common_dir', 'git_object_dir', 'git_index_file',
'git_graft_file', and 'namespace' to be stored in 'the_repository'.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Brandon Williams
2017-06-22 11:43:33 -07:00
committed by Junio C Hamano
parent 359efeffc1
commit c14c234f22
4 changed files with 34 additions and 53 deletions

11
path.c
View File

@ -2,6 +2,7 @@
* Utilities for paths and pathnames
*/
#include "cache.h"
#include "repository.h"
#include "strbuf.h"
#include "string-list.h"
#include "dir.h"
@ -355,7 +356,7 @@ void report_linked_checkout_garbage(void)
const struct common_dir *p;
int len;
if (!git_common_dir_env)
if (!the_repository->different_commondir)
return;
strbuf_addf(&sb, "%s/", get_git_dir());
len = sb.len;
@ -374,17 +375,17 @@ void report_linked_checkout_garbage(void)
static void adjust_git_path(struct strbuf *buf, int git_dir_len)
{
const char *base = buf->buf + git_dir_len;
if (git_graft_env && is_dir_file(base, "info", "grafts"))
if (is_dir_file(base, "info", "grafts"))
strbuf_splice(buf, 0, buf->len,
get_graft_file(), strlen(get_graft_file()));
else if (git_index_env && !strcmp(base, "index"))
else if (!strcmp(base, "index"))
strbuf_splice(buf, 0, buf->len,
get_index_file(), strlen(get_index_file()));
else if (git_db_env && dir_prefix(base, "objects"))
else if (dir_prefix(base, "objects"))
replace_dir(buf, git_dir_len + 7, get_object_directory());
else if (git_hooks_path && dir_prefix(base, "hooks"))
replace_dir(buf, git_dir_len + 5, git_hooks_path);
else if (git_common_dir_env)
else if (the_repository->different_commondir)
update_common_dir(buf, git_dir_len, NULL);
}