Skip to content

Commit

Permalink
Change the signature of read_packed_refs()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Michael Haggerty authored and Junio C Hamano committed Aug 14, 2011
1 parent 4349a66 commit db4dd93
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions refs.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ static void invalidate_cached_refs(void)
clear_cached_refs(get_cached_refs(NULL));
}

static void read_packed_refs(FILE *f, struct cached_refs *cached_refs)
static struct ref_list *read_packed_refs(FILE *f)
{
struct ref_list *list = NULL;
struct ref_list *last = NULL;
Expand Down Expand Up @@ -235,7 +235,7 @@ static void read_packed_refs(FILE *f, struct cached_refs *cached_refs)
!get_sha1_hex(refline + 1, sha1))
hashcpy(last->peeled, sha1);
}
cached_refs->packed = sort_ref_list(list);
return sort_ref_list(list);
}

void add_extra_ref(const char *name, const unsigned char *sha1, int flag)
Expand Down Expand Up @@ -264,7 +264,7 @@ static struct ref_list *get_packed_refs(const char *submodule)
f = fopen(packed_refs_file, "r");
refs->packed = NULL;
if (f) {
read_packed_refs(f, refs);
refs->packed = read_packed_refs(f);
fclose(f);
}
refs->did_packed = 1;
Expand Down Expand Up @@ -391,17 +391,17 @@ static struct ref_list *get_loose_refs(const char *submodule)
static int resolve_gitlink_packed_ref(char *name, int pathlen, const char *refname, unsigned char *result)
{
FILE *f;
struct cached_refs refs;
struct ref_list *packed_refs;
struct ref_list *ref;
int retval;

strcpy(name + pathlen, "packed-refs");
f = fopen(name, "r");
if (!f)
return -1;
read_packed_refs(f, &refs);
packed_refs = read_packed_refs(f);
fclose(f);
ref = refs.packed;
ref = packed_refs;
retval = -1;
while (ref) {
if (!strcmp(ref->name, refname)) {
Expand All @@ -411,7 +411,7 @@ static int resolve_gitlink_packed_ref(char *name, int pathlen, const char *refna
}
ref = ref->next;
}
free_ref_list(refs.packed);
free_ref_list(packed_refs);
return retval;
}

Expand Down

0 comments on commit db4dd93

Please sign in to comment.