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>

Michael Haggerty committed Dec 12, 2011 at 06:38 UTC dd73ecd1bc8903036d58cf7afb0010ef4aaf8695
1 file changed +5 -9
refs.c
+5 -9
@@ -73,13 +73,8 @@ static struct ref_entry *create_ref_entry(const char *refname,
73 }
74
75 /* 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)
77 {
80 - struct ref_entry *ref = create_ref_entry(refname, sha1, flag, check_name);
81 - if (new_ref)
82 - *new_ref = ref;
78 ALLOC_GROW(refs->refs, refs->nr + 1, refs->alloc);
79 refs->refs[refs->nr++] = ref;
80 }
@@ -262,7 +257,8 @@ static void read_packed_refs(FILE *f, struct ref_array *array)
257
258 refname = parse_ref_line(refline, sha1);
259 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);
262 continue;
263 }
264 if (last &&
@@ -277,7 +273,7 @@ static void read_packed_refs(FILE *f, struct ref_array *array)
273
274 void add_extra_ref(const char *refname, const unsigned char *sha1, int flag)
275 {
280 - add_ref(refname, sha1, flag, 0, &extra_refs, NULL);
276 + add_ref(&extra_refs, create_ref_entry(refname, sha1, flag, 0));
277 }
278
279 void clear_extra_refs(void)
@@ -363,7 +359,7 @@ static void get_ref_dir(struct ref_cache *refs, const char *base,
359 hashclr(sha1);
360 flag |= REF_ISBROKEN;
361 }
366 - add_ref(refname, sha1, flag, 1, array, NULL);
362 + add_ref(array, create_ref_entry(refname, sha1, flag, 1));
363 }
364 free(refname);
365 closedir(dir);