diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2017-03-26 09:42:31 +0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-03-27 10:23:40 -0700 |
commit | 5d0bc90e5de37c708f0856aef2c7b353a9d5030b (patch) | |
tree | 10f9023727c946102a744b3e318a405c05d6e531 /refs | |
parent | bbbb7de7ac69e66c9263bd0e220172fe717b3f54 (diff) | |
download | git-5d0bc90e5de37c708f0856aef2c7b353a9d5030b.tar.gz |
refs: move submodule code out of files-backend.c
files-backend is now initialized with a $GIT_DIR. Converting a submodule
path to where real submodule gitdir is located is done in get_ref_store().
This gives a slight performance improvement for submodules since we
don't convert submodule path to gitdir at every backend call like
before. We pay that once at ref-store creation.
More cleanup in files_downcast() and files_assert_main_repository()
follows shortly. It's separate to keep noises from this patch.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs')
-rw-r--r-- | refs/files-backend.c | 24 | ||||
-rw-r--r-- | refs/refs-internal.h | 9 |
2 files changed, 6 insertions, 27 deletions
diff --git a/refs/files-backend.c b/refs/files-backend.c index b62f374f9c..490f05a6f4 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -917,12 +917,6 @@ struct packed_ref_cache { struct files_ref_store { struct ref_store base; - /* - * The name of the submodule represented by this object, or - * NULL if it represents the main repository's reference - * store: - */ - const char *submodule; char *gitdir; char *gitcommondir; char *packed_refs_path; @@ -982,22 +976,14 @@ static void clear_loose_ref_cache(struct files_ref_store *refs) * Create a new submodule ref cache and add it to the internal * set of caches. */ -static struct ref_store *files_ref_store_create(const char *submodule) +static struct ref_store *files_ref_store_create(const char *gitdir) { struct files_ref_store *refs = xcalloc(1, sizeof(*refs)); struct ref_store *ref_store = (struct ref_store *)refs; struct strbuf sb = STRBUF_INIT; - const char *gitdir = get_git_dir(); base_ref_store_init(ref_store, &refs_be_files); - if (submodule) { - refs->submodule = xstrdup(submodule); - refs->packed_refs_path = git_pathdup_submodule( - refs->submodule, "packed-refs"); - return ref_store; - } - refs->gitdir = xstrdup(gitdir); get_common_dir_noenv(&sb, gitdir); refs->gitcommondir = strbuf_detach(&sb, NULL); @@ -1014,8 +1000,7 @@ static struct ref_store *files_ref_store_create(const char *submodule) static void files_assert_main_repository(struct files_ref_store *refs, const char *caller) { - if (refs->submodule) - die("BUG: %s called for a submodule", caller); + /* This function is to be fixed up in the next patch */ } /* @@ -1206,11 +1191,6 @@ static void files_ref_path(struct files_ref_store *refs, struct strbuf *sb, const char *refname) { - if (refs->submodule) { - strbuf_git_path_submodule(sb, refs->submodule, "%s", refname); - return; - } - switch (ref_type(refname)) { case REF_TYPE_PER_WORKTREE: case REF_TYPE_PSEUDOREF: diff --git a/refs/refs-internal.h b/refs/refs-internal.h index f732473e1d..dfa1817929 100644 --- a/refs/refs-internal.h +++ b/refs/refs-internal.h @@ -482,12 +482,11 @@ struct ref_store; /* refs backends */ /* - * Initialize the ref_store for the specified submodule, or for the - * main repository if submodule == NULL. These functions should call - * base_ref_store_init() to initialize the shared part of the - * ref_store and to record the ref_store for later lookup. + * Initialize the ref_store for the specified gitdir. These functions + * should call base_ref_store_init() to initialize the shared part of + * the ref_store and to record the ref_store for later lookup. */ -typedef struct ref_store *ref_store_init_fn(const char *submodule); +typedef struct ref_store *ref_store_init_fn(const char *gitdir); typedef int ref_init_db_fn(struct ref_store *refs, struct strbuf *err); |