Change the signature of read_packed_refs()
Change it to return a (struct ref_list *) instead of writing into a cached_refs structure. (This removes the need to create a cached_refs structure in resolve_gitlink_packed_ref(), where it is otherwise unneeded.) Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty committed
Aug 13, 2011 at 00:36 UTC
db4dd93a4a3553c61b416db924520b55bfee5f7e
1 file changed
+7
-7
refs.c
+7
-7
@@ -203,7 +203,7 @@ static void invalidate_cached_refs(void)
203
clear_cached_refs(get_cached_refs(NULL));
204
}
205
206
-static void read_packed_refs(FILE *f, struct cached_refs *cached_refs)
206
+static struct ref_list *read_packed_refs(FILE *f)
207
{
208
struct ref_list *list = NULL;
209
struct ref_list *last = NULL;
@@ -235,7 +235,7 @@ static void read_packed_refs(FILE *f, struct cached_refs *cached_refs)
235
!get_sha1_hex(refline + 1, sha1))
236
hashcpy(last->peeled, sha1);
237
}
238
- cached_refs->packed = sort_ref_list(list);
238
+ return sort_ref_list(list);
239
}
240
241
void add_extra_ref(const char *name, const unsigned char *sha1, int flag)
@@ -264,7 +264,7 @@ static struct ref_list *get_packed_refs(const char *submodule)
264
f = fopen(packed_refs_file, "r");
265
refs->packed = NULL;
266
if (f) {
267
- read_packed_refs(f, refs);
267
+ refs->packed = read_packed_refs(f);
268
fclose(f);
269
}
270
refs->did_packed = 1;
@@ -391,7 +391,7 @@ static struct ref_list *get_loose_refs(const char *submodule)
391
static int resolve_gitlink_packed_ref(char *name, int pathlen, const char *refname, unsigned char *result)
392
{
393
FILE *f;
394
- struct cached_refs refs;
394
+ struct ref_list *packed_refs;
395
struct ref_list *ref;
396
int retval;
397
@@ -399,9 +399,9 @@ static int resolve_gitlink_packed_ref(char *name, int pathlen, const char *refna
399
f = fopen(name, "r");
400
if (!f)
401
return -1;
402
- read_packed_refs(f, &refs);
402
+ packed_refs = read_packed_refs(f);
403
fclose(f);
404
- ref = refs.packed;
404
+ ref = packed_refs;
405
retval = -1;
406
while (ref) {
407
if (!strcmp(ref->name, refname)) {
@@ -411,7 +411,7 @@ static int resolve_gitlink_packed_ref(char *name, int pathlen, const char *refna
411
}
412
ref = ref->next;
413
}
414
- free_ref_list(refs.packed);
414
+ free_ref_list(packed_refs);
415
return retval;
416
}
417