@@ -2004,37 +2004,38 @@ static int do_not_prune(int flags)
2004
2004
return (flags & (REF_ISSYMREF |REF_ISPACKED ));
2005
2005
}
2006
2006
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 )
2009
2008
{
2010
2009
struct pack_refs_cb_data * cb = cb_data ;
2011
2010
struct object * o ;
2012
2011
int is_tag_ref ;
2013
2012
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 ))
2016
2015
return 0 ;
2017
- is_tag_ref = !prefixcmp (refname , "refs/tags/" );
2016
+ is_tag_ref = !prefixcmp (entry -> name , "refs/tags/" );
2018
2017
2019
2018
/* 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 ))
2021
2021
return 0 ;
2022
2022
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 );
2024
2025
2025
- o = parse_object_or_die (sha1 , refname );
2026
+ o = parse_object_or_die (entry -> u . value . sha1 , entry -> name );
2026
2027
if (o -> type == OBJ_TAG ) {
2027
- o = deref_tag (o , refname , 0 );
2028
+ o = deref_tag (o , entry -> name , 0 );
2028
2029
if (o )
2029
2030
fprintf (cb -> refs_file , "^%s\n" ,
2030
2031
sha1_to_hex (o -> sha1 ));
2031
2032
}
2032
2033
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 ;
2035
2036
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 );
2038
2039
n -> next = cb -> ref_to_prune ;
2039
2040
cb -> ref_to_prune = n ;
2040
2041
}
@@ -2111,7 +2112,7 @@ int pack_refs(unsigned int flags)
2111
2112
/* perhaps other traits later as well */
2112
2113
fprintf (cbdata .refs_file , "# pack-refs with: peeled fully-peeled \n" );
2113
2114
2114
- for_each_ref ( pack_one_ref , & cbdata );
2115
+ do_for_each_entry ( NULL , "" , pack_one_ref , & cbdata );
2115
2116
if (ferror (cbdata .refs_file ))
2116
2117
die ("failed to write ref-pack file" );
2117
2118
if (fflush (cbdata .refs_file ) || fsync (fd ) || fclose (cbdata .refs_file ))
0 commit comments