@@ -115,7 +115,7 @@ static int receive_pack_config(const char *var, const char *value, void *cb)
115
115
return git_default_config (var , value , cb );
116
116
}
117
117
118
- static int show_ref (const char * path , const unsigned char * sha1 , int flag , void * cb_data )
118
+ static void show_ref (const char * path , const unsigned char * sha1 )
119
119
{
120
120
if (sent_capabilities )
121
121
packet_write (1 , "%s %s\n" , sha1_to_hex (sha1 ), path );
@@ -125,10 +125,9 @@ static int show_ref(const char *path, const unsigned char *sha1, int flag, void
125
125
" report-status delete-refs side-band-64k" ,
126
126
prefer_ofs_delta ? " ofs-delta" : "" );
127
127
sent_capabilities = 1 ;
128
- return 0 ;
129
128
}
130
129
131
- static int show_ref_cb (const char * path , const unsigned char * sha1 , int flag , void * cb_data )
130
+ static int show_ref_cb (const char * path , const unsigned char * sha1 , int flag , void * unused )
132
131
{
133
132
path = strip_namespace (path );
134
133
/*
@@ -141,15 +140,33 @@ static int show_ref_cb(const char *path, const unsigned char *sha1, int flag, vo
141
140
*/
142
141
if (!path )
143
142
path = ".have" ;
144
- return show_ref (path , sha1 , flag , cb_data );
143
+ show_ref (path , sha1 );
144
+ return 0 ;
145
+ }
146
+
147
+ static void show_one_alternate_sha1 (const unsigned char sha1 [20 ], void * unused )
148
+ {
149
+ show_ref (".have" , sha1 );
150
+ }
151
+
152
+ static void collect_one_alternate_ref (const struct ref * ref , void * data )
153
+ {
154
+ struct sha1_array * sa = data ;
155
+ sha1_array_append (sa , ref -> old_sha1 );
145
156
}
146
157
147
158
static void write_head_info (void )
148
159
{
160
+ struct sha1_array sa = SHA1_ARRAY_INIT ;
161
+ for_each_alternate_ref (collect_one_alternate_ref , & sa );
162
+ sha1_array_for_each_unique (& sa , show_one_alternate_sha1 , NULL );
163
+ sha1_array_clear (& sa );
149
164
for_each_ref (show_ref_cb , NULL );
150
165
if (!sent_capabilities )
151
- show_ref ("capabilities^{}" , null_sha1 , 0 , NULL );
166
+ show_ref ("capabilities^{}" , null_sha1 );
152
167
168
+ /* EOF */
169
+ packet_flush (1 );
153
170
}
154
171
155
172
struct command {
@@ -869,25 +886,6 @@ static int delete_only(struct command *commands)
869
886
return 1 ;
870
887
}
871
888
872
- static void add_one_alternate_sha1 (const unsigned char sha1 [20 ], void * unused )
873
- {
874
- add_extra_ref (".have" , sha1 , 0 );
875
- }
876
-
877
- static void collect_one_alternate_ref (const struct ref * ref , void * data )
878
- {
879
- struct sha1_array * sa = data ;
880
- sha1_array_append (sa , ref -> old_sha1 );
881
- }
882
-
883
- static void add_alternate_refs (void )
884
- {
885
- struct sha1_array sa = SHA1_ARRAY_INIT ;
886
- for_each_alternate_ref (collect_one_alternate_ref , & sa );
887
- sha1_array_for_each_unique (& sa , add_one_alternate_sha1 , NULL );
888
- sha1_array_clear (& sa );
889
- }
890
-
891
889
int cmd_receive_pack (int argc , const char * * argv , const char * prefix )
892
890
{
893
891
int advertise_refs = 0 ;
@@ -937,12 +935,7 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
937
935
unpack_limit = receive_unpack_limit ;
938
936
939
937
if (advertise_refs || !stateless_rpc ) {
940
- add_alternate_refs ();
941
938
write_head_info ();
942
- clear_extra_refs ();
943
-
944
- /* EOF */
945
- packet_flush (1 );
946
939
}
947
940
if (advertise_refs )
948
941
return 0 ;
0 commit comments