Store the submodule name in struct cached_refs
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
e5dbf6056f
commit
ce40979cf8
15
refs.c
15
refs.c
@ -157,6 +157,8 @@ static struct cached_refs {
|
|||||||
char did_packed;
|
char did_packed;
|
||||||
struct ref_list *loose;
|
struct ref_list *loose;
|
||||||
struct ref_list *packed;
|
struct ref_list *packed;
|
||||||
|
/* The submodule name, or "" for the main repo. */
|
||||||
|
char name[FLEX_ARRAY];
|
||||||
} *cached_refs, *submodule_refs;
|
} *cached_refs, *submodule_refs;
|
||||||
static struct ref_list *current_ref;
|
static struct ref_list *current_ref;
|
||||||
|
|
||||||
@ -181,12 +183,17 @@ static void clear_cached_refs(struct cached_refs *ca)
|
|||||||
ca->did_loose = ca->did_packed = 0;
|
ca->did_loose = ca->did_packed = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cached_refs *create_cached_refs(void)
|
struct cached_refs *create_cached_refs(const char *submodule)
|
||||||
{
|
{
|
||||||
|
int len;
|
||||||
struct cached_refs *refs;
|
struct cached_refs *refs;
|
||||||
refs = xmalloc(sizeof(struct cached_refs));
|
if (!submodule)
|
||||||
|
submodule = "";
|
||||||
|
len = strlen(submodule) + 1;
|
||||||
|
refs = xmalloc(sizeof(struct cached_refs) + len);
|
||||||
refs->did_loose = refs->did_packed = 0;
|
refs->did_loose = refs->did_packed = 0;
|
||||||
refs->loose = refs->packed = NULL;
|
refs->loose = refs->packed = NULL;
|
||||||
|
memcpy(refs->name, submodule, len);
|
||||||
return refs;
|
return refs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,11 +207,11 @@ static struct cached_refs *get_cached_refs(const char *submodule)
|
|||||||
{
|
{
|
||||||
if (!submodule) {
|
if (!submodule) {
|
||||||
if (!cached_refs)
|
if (!cached_refs)
|
||||||
cached_refs = create_cached_refs();
|
cached_refs = create_cached_refs(submodule);
|
||||||
return cached_refs;
|
return cached_refs;
|
||||||
} else {
|
} else {
|
||||||
if (!submodule_refs)
|
if (!submodule_refs)
|
||||||
submodule_refs = create_cached_refs();
|
submodule_refs = create_cached_refs(submodule);
|
||||||
else
|
else
|
||||||
/* For now, don't reuse the refs cache for submodules. */
|
/* For now, don't reuse the refs cache for submodules. */
|
||||||
clear_cached_refs(submodule_refs);
|
clear_cached_refs(submodule_refs);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user