packed_ref_cache: remember the file-wide peeling state
Rather than store the peeling state (i.e., the one defined by traits in the `packed-refs` file header line) in a local variable in `read_packed_refs()`, store it permanently in `packed_ref_cache`. This will be needed when we stop reading all packed refs at once. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
6a9bc4034a
commit
daa45408c1
@ -18,6 +18,12 @@ struct packed_ref_cache {
|
|||||||
|
|
||||||
struct ref_cache *cache;
|
struct ref_cache *cache;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* What is the peeled state of this cache? (This is usually
|
||||||
|
* determined from the header of the "packed-refs" file.)
|
||||||
|
*/
|
||||||
|
enum { PEELED_NONE, PEELED_TAGS, PEELED_FULLY } peeled;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Count of references to the data structure in this instance,
|
* Count of references to the data structure in this instance,
|
||||||
* including the pointer from files_ref_store::packed if any.
|
* including the pointer from files_ref_store::packed if any.
|
||||||
@ -195,13 +201,13 @@ static struct packed_ref_cache *read_packed_refs(struct packed_ref_store *refs)
|
|||||||
char *buf;
|
char *buf;
|
||||||
const char *pos, *eol, *eof;
|
const char *pos, *eol, *eof;
|
||||||
struct strbuf tmp = STRBUF_INIT;
|
struct strbuf tmp = STRBUF_INIT;
|
||||||
enum { PEELED_NONE, PEELED_TAGS, PEELED_FULLY } peeled = PEELED_NONE;
|
|
||||||
struct ref_dir *dir;
|
struct ref_dir *dir;
|
||||||
|
|
||||||
packed_refs->refs = refs;
|
packed_refs->refs = refs;
|
||||||
acquire_packed_ref_cache(packed_refs);
|
acquire_packed_ref_cache(packed_refs);
|
||||||
packed_refs->cache = create_ref_cache(NULL, NULL);
|
packed_refs->cache = create_ref_cache(NULL, NULL);
|
||||||
packed_refs->cache->root->flag &= ~REF_INCOMPLETE;
|
packed_refs->cache->root->flag &= ~REF_INCOMPLETE;
|
||||||
|
packed_refs->peeled = PEELED_NONE;
|
||||||
|
|
||||||
fd = open(refs->path, O_RDONLY);
|
fd = open(refs->path, O_RDONLY);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
@ -244,9 +250,9 @@ static struct packed_ref_cache *read_packed_refs(struct packed_ref_store *refs)
|
|||||||
string_list_split_in_place(&traits, p, ' ', -1);
|
string_list_split_in_place(&traits, p, ' ', -1);
|
||||||
|
|
||||||
if (unsorted_string_list_has_string(&traits, "fully-peeled"))
|
if (unsorted_string_list_has_string(&traits, "fully-peeled"))
|
||||||
peeled = PEELED_FULLY;
|
packed_refs->peeled = PEELED_FULLY;
|
||||||
else if (unsorted_string_list_has_string(&traits, "peeled"))
|
else if (unsorted_string_list_has_string(&traits, "peeled"))
|
||||||
peeled = PEELED_TAGS;
|
packed_refs->peeled = PEELED_TAGS;
|
||||||
/* perhaps other traits later as well */
|
/* perhaps other traits later as well */
|
||||||
|
|
||||||
/* The "+ 1" is for the LF character. */
|
/* The "+ 1" is for the LF character. */
|
||||||
@ -282,8 +288,9 @@ static struct packed_ref_cache *read_packed_refs(struct packed_ref_store *refs)
|
|||||||
oidclr(&oid);
|
oidclr(&oid);
|
||||||
flag |= REF_BAD_NAME | REF_ISBROKEN;
|
flag |= REF_BAD_NAME | REF_ISBROKEN;
|
||||||
}
|
}
|
||||||
if (peeled == PEELED_FULLY ||
|
if (packed_refs->peeled == PEELED_FULLY ||
|
||||||
(peeled == PEELED_TAGS && starts_with(refname, "refs/tags/")))
|
(packed_refs->peeled == PEELED_TAGS &&
|
||||||
|
starts_with(refname, "refs/tags/")))
|
||||||
flag |= REF_KNOWS_PEELED;
|
flag |= REF_KNOWS_PEELED;
|
||||||
entry = create_ref_entry(refname, &oid, flag);
|
entry = create_ref_entry(refname, &oid, flag);
|
||||||
add_ref_entry(dir, entry);
|
add_ref_entry(dir, entry);
|
||||||
|
Loading…
Reference in New Issue
Block a user