[PATCH 3/6] Change the signature of read_packed_refs()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxx>
---
 refs.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/refs.c b/refs.c
index 89840d7..e043555 100644
--- a/refs.c
+++ b/refs.c
@@ -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;
@@ -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)
@@ -262,7 +262,7 @@ static struct ref_list *get_packed_refs(const char *submodule)
 		FILE *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;
@@ -389,7 +389,7 @@ 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;
 
@@ -397,9 +397,9 @@ static int resolve_gitlink_packed_ref(char *name, int pathlen, const char *refna
 	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)) {
@@ -409,7 +409,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;
 }
 
-- 
1.7.6.8.gd2879

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]