@@ -176,54 +176,44 @@ char *sha1_file_name(const unsigned char *sha1)
176176 return base ;
177177}
178178
179- char * sha1_pack_name (const unsigned char * sha1 )
179+ static char * sha1_get_pack_name (const unsigned char * sha1 ,
180+ char * * name , char * * base )
180181{
181182 static const char hex [] = "0123456789abcdef" ;
182- static char * name , * base , * buf ;
183+ char * buf ;
183184 int i ;
184185
185- if (!base ) {
186+ if (!* base ) {
186187 const char * sha1_file_directory = get_object_directory ();
187188 int len = strlen (sha1_file_directory );
188- base = xmalloc (len + 60 );
189- sprintf (base , "%s/pack/pack-1234567890123456789012345678901234567890.pack" , sha1_file_directory );
190- name = base + len + 11 ;
189+ * base = xmalloc (len + 60 );
190+ sprintf (* base , "%s/pack/pack-1234567890123456789012345678901234567890.pack" , sha1_file_directory );
191+ * name = * base + len + 11 ;
191192 }
192193
193- buf = name ;
194+ buf = * name ;
194195
195196 for (i = 0 ; i < 20 ; i ++ ) {
196197 unsigned int val = * sha1 ++ ;
197198 * buf ++ = hex [val >> 4 ];
198199 * buf ++ = hex [val & 0xf ];
199200 }
200201
201- return base ;
202+ return * base ;
202203}
203204
204- char * sha1_pack_index_name (const unsigned char * sha1 )
205+ char * sha1_pack_name (const unsigned char * sha1 )
205206{
206- static const char hex [] = "0123456789abcdef" ;
207- static char * name , * base , * buf ;
208- int i ;
209-
210- if (!base ) {
211- const char * sha1_file_directory = get_object_directory ();
212- int len = strlen (sha1_file_directory );
213- base = xmalloc (len + 60 );
214- sprintf (base , "%s/pack/pack-1234567890123456789012345678901234567890.idx" , sha1_file_directory );
215- name = base + len + 11 ;
216- }
207+ static char * name , * base ;
217208
218- buf = name ;
209+ return sha1_get_pack_name (sha1 , & name , & base );
210+ }
219211
220- for (i = 0 ; i < 20 ; i ++ ) {
221- unsigned int val = * sha1 ++ ;
222- * buf ++ = hex [val >> 4 ];
223- * buf ++ = hex [val & 0xf ];
224- }
212+ char * sha1_pack_index_name (const unsigned char * sha1 )
213+ {
214+ static char * name , * base ;
225215
226- return base ;
216+ return sha1_get_pack_name ( sha1 , & name , & base ) ;
227217}
228218
229219struct alternate_object_database * alt_odb_list ;
0 commit comments