add_ref(): take a (struct ref_entry *) parameter
Take a pointer to the ref_entry to add to the array, rather than creating the ref_entry within the function. This opens the way to having multiple kinds of ref_entries. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
cddc42587c
commit
dd73ecd1bc
14
refs.c
14
refs.c
@ -73,13 +73,8 @@ static struct ref_entry *create_ref_entry(const char *refname,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Add a ref_entry to the end of the ref_array (unsorted). */
|
/* Add a ref_entry to the end of the ref_array (unsorted). */
|
||||||
static void add_ref(const char *refname, const unsigned char *sha1,
|
static void add_ref(struct ref_array *refs, struct ref_entry *ref)
|
||||||
int flag, int check_name, struct ref_array *refs,
|
|
||||||
struct ref_entry **new_ref)
|
|
||||||
{
|
{
|
||||||
struct ref_entry *ref = create_ref_entry(refname, sha1, flag, check_name);
|
|
||||||
if (new_ref)
|
|
||||||
*new_ref = ref;
|
|
||||||
ALLOC_GROW(refs->refs, refs->nr + 1, refs->alloc);
|
ALLOC_GROW(refs->refs, refs->nr + 1, refs->alloc);
|
||||||
refs->refs[refs->nr++] = ref;
|
refs->refs[refs->nr++] = ref;
|
||||||
}
|
}
|
||||||
@ -262,7 +257,8 @@ static void read_packed_refs(FILE *f, struct ref_array *array)
|
|||||||
|
|
||||||
refname = parse_ref_line(refline, sha1);
|
refname = parse_ref_line(refline, sha1);
|
||||||
if (refname) {
|
if (refname) {
|
||||||
add_ref(refname, sha1, flag, 1, array, &last);
|
last = create_ref_entry(refname, sha1, flag, 1);
|
||||||
|
add_ref(array, last);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (last &&
|
if (last &&
|
||||||
@ -277,7 +273,7 @@ static void read_packed_refs(FILE *f, struct ref_array *array)
|
|||||||
|
|
||||||
void add_extra_ref(const char *refname, const unsigned char *sha1, int flag)
|
void add_extra_ref(const char *refname, const unsigned char *sha1, int flag)
|
||||||
{
|
{
|
||||||
add_ref(refname, sha1, flag, 0, &extra_refs, NULL);
|
add_ref(&extra_refs, create_ref_entry(refname, sha1, flag, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear_extra_refs(void)
|
void clear_extra_refs(void)
|
||||||
@ -363,7 +359,7 @@ static void get_ref_dir(struct ref_cache *refs, const char *base,
|
|||||||
hashclr(sha1);
|
hashclr(sha1);
|
||||||
flag |= REF_ISBROKEN;
|
flag |= REF_ISBROKEN;
|
||||||
}
|
}
|
||||||
add_ref(refname, sha1, flag, 1, array, NULL);
|
add_ref(array, create_ref_entry(refname, sha1, flag, 1));
|
||||||
}
|
}
|
||||||
free(refname);
|
free(refname);
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
|
Loading…
Reference in New Issue
Block a user