remote: rewrite functions to take object_id arguments
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty committed
May 25, 2015 at 18:39 UTC
455ade659823ab01e7c1c5ec91be65c622319b01
1 file changed
+8
-11
remote.c
+8
-11
@@ -2024,7 +2024,8 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb)
2024
return 1;
2025
}
2026
2027
-static int one_local_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
2027
+static int one_local_ref(const char *refname, const struct object_id *oid,
2028
+ int flag, void *cb_data)
2029
{
2030
struct ref ***local_tail = cb_data;
2031
struct ref *ref;
@@ -2036,7 +2037,7 @@ static int one_local_ref(const char *refname, const unsigned char *sha1, int fla
2037
2038
len = strlen(refname) + 1;
2039
ref = xcalloc(1, sizeof(*ref) + len);
2039
- hashcpy(ref->new_sha1, sha1);
2040
+ hashcpy(ref->new_sha1, oid->hash);
2041
memcpy(ref->name, refname, len);
2042
**local_tail = ref;
2043
*local_tail = &ref->next;
@@ -2046,10 +2047,8 @@ static int one_local_ref(const char *refname, const unsigned char *sha1, int fla
2047
struct ref *get_local_heads(void)
2048
{
2049
struct ref *local_refs = NULL, **local_tail = &local_refs;
2049
- struct each_ref_fn_sha1_adapter wrapped_one_local_ref =
2050
- {one_local_ref, &local_tail};
2050
2052
- for_each_ref(each_ref_fn_adapter, &wrapped_one_local_ref);
2051
+ for_each_ref(one_local_ref, &local_tail);
2052
return local_refs;
2053
}
2054
@@ -2101,8 +2100,8 @@ struct stale_heads_info {
2100
int ref_count;
2101
};
2102
2104
-static int get_stale_heads_cb(const char *refname,
2105
- const unsigned char *sha1, int flags, void *cb_data)
2103
+static int get_stale_heads_cb(const char *refname, const struct object_id *oid,
2104
+ int flags, void *cb_data)
2105
{
2106
struct stale_heads_info *info = cb_data;
2107
struct string_list matches = STRING_LIST_INIT_DUP;
@@ -2131,7 +2130,7 @@ static int get_stale_heads_cb(const char *refname,
2130
2131
if (stale) {
2132
struct ref *ref = make_linked_ref(refname, &info->stale_refs_tail);
2134
- hashcpy(ref->new_sha1, sha1);
2133
+ hashcpy(ref->new_sha1, oid->hash);
2134
}
2135
2136
clean_exit:
@@ -2144,8 +2143,6 @@ struct ref *get_stale_heads(struct refspec *refs, int ref_count, struct ref *fet
2143
struct ref *ref, *stale_refs = NULL;
2144
struct string_list ref_names = STRING_LIST_INIT_NODUP;
2145
struct stale_heads_info info;
2147
- struct each_ref_fn_sha1_adapter wrapped_get_stale_heads_cb =
2148
- {get_stale_heads_cb, &info};
2146
2147
info.ref_names = &ref_names;
2148
info.stale_refs_tail = &stale_refs;
@@ -2154,7 +2151,7 @@ struct ref *get_stale_heads(struct refspec *refs, int ref_count, struct ref *fet
2151
for (ref = fetch_map; ref; ref = ref->next)
2152
string_list_append(&ref_names, ref->name);
2153
string_list_sort(&ref_names);
2157
- for_each_ref(each_ref_fn_adapter, &wrapped_get_stale_heads_cb);
2154
+ for_each_ref(get_stale_heads_cb, &info);
2155
string_list_clear(&ref_names, 0);
2156
return stale_refs;
2157
}