@@ -179,13 +179,15 @@ static void add_merge_config(struct ref **head,
179179 }
180180}
181181
182- static int add_existing (const char * refname , const unsigned char * sha1 ,
182+ static int add_existing (const char * refname , const struct object_id * oid ,
183183 int flag , void * cbdata )
184184{
185185 struct string_list * list = (struct string_list * )cbdata ;
186186 struct string_list_item * item = string_list_insert (list , refname );
187- item -> util = xmalloc (20 );
188- hashcpy (item -> util , sha1 );
187+ struct object_id * old_oid = xmalloc (sizeof (* old_oid ));
188+
189+ oidcpy (old_oid , oid );
190+ item -> util = old_oid ;
189191 return 0 ;
190192}
191193
@@ -208,10 +210,8 @@ static void find_non_local_tags(struct transport *transport,
208210 struct string_list remote_refs = STRING_LIST_INIT_NODUP ;
209211 const struct ref * ref ;
210212 struct string_list_item * item = NULL ;
211- struct each_ref_fn_sha1_adapter wrapped_add_existing =
212- {add_existing , & existing_refs };
213213
214- for_each_ref (each_ref_fn_adapter , & wrapped_add_existing );
214+ for_each_ref (add_existing , & existing_refs );
215215 for (ref = transport_get_remote_refs (transport ); ref ; ref = ref -> next ) {
216216 if (!starts_with (ref -> name , "refs/tags/" ))
217217 continue ;
@@ -886,10 +886,8 @@ static int do_fetch(struct transport *transport,
886886 struct ref * rm ;
887887 int autotags = (transport -> remote -> fetch_tags == 1 );
888888 int retcode = 0 ;
889- struct each_ref_fn_sha1_adapter wrapped_add_existing =
890- {add_existing , & existing_refs };
891889
892- for_each_ref (each_ref_fn_adapter , & wrapped_add_existing );
890+ for_each_ref (add_existing , & existing_refs );
893891
894892 if (tags == TAGS_DEFAULT ) {
895893 if (transport -> remote -> fetch_tags == 2 )
@@ -917,9 +915,10 @@ static int do_fetch(struct transport *transport,
917915 struct string_list_item * peer_item =
918916 string_list_lookup (& existing_refs ,
919917 rm -> peer_ref -> name );
920- if (peer_item )
921- hashcpy (rm -> peer_ref -> old_sha1 ,
922- peer_item -> util );
918+ if (peer_item ) {
919+ struct object_id * old_oid = peer_item -> util ;
920+ hashcpy (rm -> peer_ref -> old_sha1 , old_oid -> hash );
921+ }
923922 }
924923 }
925924
0 commit comments