Skip to content

Commit dd73ecd

Browse files
mhaggergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cddc425 commit dd73ecd

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

refs.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,8 @@ static struct ref_entry *create_ref_entry(const char *refname,
7373
}
7474

7575
/* Add a ref_entry to the end of the ref_array (unsorted). */
76-
static void add_ref(const char *refname, const unsigned char *sha1,
77-
int flag, int check_name, struct ref_array *refs,
78-
struct ref_entry **new_ref)
76+
static void add_ref(struct ref_array *refs, struct ref_entry *ref)
7977
{
80-
struct ref_entry *ref = create_ref_entry(refname, sha1, flag, check_name);
81-
if (new_ref)
82-
*new_ref = ref;
8378
ALLOC_GROW(refs->refs, refs->nr + 1, refs->alloc);
8479
refs->refs[refs->nr++] = ref;
8580
}
@@ -262,7 +257,8 @@ static void read_packed_refs(FILE *f, struct ref_array *array)
262257

263258
refname = parse_ref_line(refline, sha1);
264259
if (refname) {
265-
add_ref(refname, sha1, flag, 1, array, &last);
260+
last = create_ref_entry(refname, sha1, flag, 1);
261+
add_ref(array, last);
266262
continue;
267263
}
268264
if (last &&
@@ -277,7 +273,7 @@ static void read_packed_refs(FILE *f, struct ref_array *array)
277273

278274
void add_extra_ref(const char *refname, const unsigned char *sha1, int flag)
279275
{
280-
add_ref(refname, sha1, flag, 0, &extra_refs, NULL);
276+
add_ref(&extra_refs, create_ref_entry(refname, sha1, flag, 0));
281277
}
282278

283279
void clear_extra_refs(void)
@@ -363,7 +359,7 @@ static void get_ref_dir(struct ref_cache *refs, const char *base,
363359
hashclr(sha1);
364360
flag |= REF_ISBROKEN;
365361
}
366-
add_ref(refname, sha1, flag, 1, array, NULL);
362+
add_ref(array, create_ref_entry(refname, sha1, flag, 1));
367363
}
368364
free(refname);
369365
closedir(dir);

0 commit comments

Comments
 (0)