зеркало из https://github.com/microsoft/git.git
refs: move gitdir into base ref_store
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
4877c6c738
Коммит
5085aef4c8
|
@ -67,7 +67,6 @@ struct files_ref_store {
|
|||
struct ref_store base;
|
||||
unsigned int store_flags;
|
||||
|
||||
char *gitdir;
|
||||
char *gitcommondir;
|
||||
|
||||
struct ref_cache *loose;
|
||||
|
@ -94,18 +93,17 @@ static struct ref_store *files_ref_store_create(const char *gitdir,
|
|||
struct ref_store *ref_store = (struct ref_store *)refs;
|
||||
struct strbuf sb = STRBUF_INIT;
|
||||
|
||||
ref_store->gitdir = xstrdup(gitdir);
|
||||
base_ref_store_init(ref_store, &refs_be_files);
|
||||
refs->store_flags = flags;
|
||||
|
||||
refs->gitdir = xstrdup(gitdir);
|
||||
get_common_dir_noenv(&sb, gitdir);
|
||||
refs->gitcommondir = strbuf_detach(&sb, NULL);
|
||||
strbuf_addf(&sb, "%s/packed-refs", refs->gitcommondir);
|
||||
refs->packed_ref_store = packed_ref_store_create(sb.buf, flags);
|
||||
strbuf_release(&sb);
|
||||
|
||||
chdir_notify_reparent("files-backend $GIT_DIR",
|
||||
&refs->gitdir);
|
||||
chdir_notify_reparent("files-backend $GIT_DIR", &refs->base.gitdir);
|
||||
chdir_notify_reparent("files-backend $GIT_COMMONDIR",
|
||||
&refs->gitcommondir);
|
||||
|
||||
|
@ -176,7 +174,7 @@ static void files_reflog_path(struct files_ref_store *refs,
|
|||
switch (ref_type(refname)) {
|
||||
case REF_TYPE_PER_WORKTREE:
|
||||
case REF_TYPE_PSEUDOREF:
|
||||
strbuf_addf(sb, "%s/logs/%s", refs->gitdir, refname);
|
||||
strbuf_addf(sb, "%s/logs/%s", refs->base.gitdir, refname);
|
||||
break;
|
||||
case REF_TYPE_OTHER_PSEUDOREF:
|
||||
case REF_TYPE_MAIN_PSEUDOREF:
|
||||
|
@ -198,7 +196,7 @@ static void files_ref_path(struct files_ref_store *refs,
|
|||
switch (ref_type(refname)) {
|
||||
case REF_TYPE_PER_WORKTREE:
|
||||
case REF_TYPE_PSEUDOREF:
|
||||
strbuf_addf(sb, "%s/%s", refs->gitdir, refname);
|
||||
strbuf_addf(sb, "%s/%s", refs->base.gitdir, refname);
|
||||
break;
|
||||
case REF_TYPE_MAIN_PSEUDOREF:
|
||||
if (!skip_prefix(refname, "main-worktree/", &refname))
|
||||
|
@ -2203,12 +2201,11 @@ static struct ref_iterator *files_reflog_iterator_begin(struct ref_store *ref_st
|
|||
files_downcast(ref_store, REF_STORE_READ,
|
||||
"reflog_iterator_begin");
|
||||
|
||||
if (!strcmp(refs->gitdir, refs->gitcommondir)) {
|
||||
if (!strcmp(refs->base.gitdir, refs->gitcommondir)) {
|
||||
return reflog_iterator_begin(ref_store, refs->gitcommondir);
|
||||
} else {
|
||||
return merge_ref_iterator_begin(
|
||||
0,
|
||||
reflog_iterator_begin(ref_store, refs->gitdir),
|
||||
0, reflog_iterator_begin(ref_store, refs->base.gitdir),
|
||||
reflog_iterator_begin(ref_store, refs->gitcommondir),
|
||||
reflog_iterator_select, refs);
|
||||
}
|
||||
|
|
|
@ -200,6 +200,7 @@ struct ref_store *packed_ref_store_create(const char *path,
|
|||
struct ref_store *ref_store = (struct ref_store *)refs;
|
||||
|
||||
base_ref_store_init(ref_store, &refs_be_packed);
|
||||
ref_store->gitdir = xstrdup(path);
|
||||
refs->store_flags = store_flags;
|
||||
|
||||
refs->path = xstrdup(path);
|
||||
|
|
|
@ -672,6 +672,9 @@ extern struct ref_storage_be refs_be_packed;
|
|||
struct ref_store {
|
||||
/* The backend describing this ref_store's storage scheme: */
|
||||
const struct ref_storage_be *be;
|
||||
|
||||
/* The gitdir that this ref_store applies to: */
|
||||
char *gitdir;
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
Загрузка…
Ссылка в новой задаче