@@ -2004,37 +2004,38 @@ static int do_not_prune(int flags)
20042004 return (flags & (REF_ISSYMREF |REF_ISPACKED ));
20052005}
20062006
2007- static int pack_one_ref (const char * refname , const unsigned char * sha1 ,
2008- int flags , void * cb_data )
2007+ static int pack_one_ref (struct ref_entry * entry , void * cb_data )
20092008{
20102009 struct pack_refs_cb_data * cb = cb_data ;
20112010 struct object * o ;
20122011 int is_tag_ref ;
20132012
2014- /* Do not pack the symbolic refs */
2015- if ((flags & REF_ISSYMREF ))
2013+ /* Do not pack symbolic or broken refs: */
2014+ if ((entry -> flag & REF_ISSYMREF ) || ! ref_resolves_to_object ( entry ))
20162015 return 0 ;
2017- is_tag_ref = !prefixcmp (refname , "refs/tags/" );
2016+ is_tag_ref = !prefixcmp (entry -> name , "refs/tags/" );
20182017
20192018 /* ALWAYS pack refs that were already packed or are tags */
2020- if (!(cb -> flags & PACK_REFS_ALL ) && !is_tag_ref && !(flags & REF_ISPACKED ))
2019+ if (!(cb -> flags & PACK_REFS_ALL ) && !is_tag_ref &&
2020+ !(entry -> flag & REF_ISPACKED ))
20212021 return 0 ;
20222022
2023- fprintf (cb -> refs_file , "%s %s\n" , sha1_to_hex (sha1 ), refname );
2023+ fprintf (cb -> refs_file , "%s %s\n" , sha1_to_hex (entry -> u .value .sha1 ),
2024+ entry -> name );
20242025
2025- o = parse_object_or_die (sha1 , refname );
2026+ o = parse_object_or_die (entry -> u . value . sha1 , entry -> name );
20262027 if (o -> type == OBJ_TAG ) {
2027- o = deref_tag (o , refname , 0 );
2028+ o = deref_tag (o , entry -> name , 0 );
20282029 if (o )
20292030 fprintf (cb -> refs_file , "^%s\n" ,
20302031 sha1_to_hex (o -> sha1 ));
20312032 }
20322033
2033- if ((cb -> flags & PACK_REFS_PRUNE ) && !do_not_prune (flags )) {
2034- int namelen = strlen (refname ) + 1 ;
2034+ if ((cb -> flags & PACK_REFS_PRUNE ) && !do_not_prune (entry -> flag )) {
2035+ int namelen = strlen (entry -> name ) + 1 ;
20352036 struct ref_to_prune * n = xcalloc (1 , sizeof (* n ) + namelen );
2036- hashcpy (n -> sha1 , sha1 );
2037- strcpy (n -> name , refname );
2037+ hashcpy (n -> sha1 , entry -> u . value . sha1 );
2038+ strcpy (n -> name , entry -> name );
20382039 n -> next = cb -> ref_to_prune ;
20392040 cb -> ref_to_prune = n ;
20402041 }
@@ -2111,7 +2112,7 @@ int pack_refs(unsigned int flags)
21112112 /* perhaps other traits later as well */
21122113 fprintf (cbdata .refs_file , "# pack-refs with: peeled fully-peeled \n" );
21132114
2114- for_each_ref ( pack_one_ref , & cbdata );
2115+ do_for_each_entry ( NULL , "" , pack_one_ref , & cbdata );
21152116 if (ferror (cbdata .refs_file ))
21162117 die ("failed to write ref-pack file" );
21172118 if (fflush (cbdata .refs_file ) || fsync (fd ) || fclose (cbdata .refs_file ))
0 commit comments