@@ -51,7 +51,6 @@ static struct pack_info {
5151 int nr_alloc ;
5252 int nr_heads ;
5353 unsigned char (* head )[20 ];
54- char dep [0 ]; /* more */
5554} * * info ;
5655static int num_pack ;
5756static const char * objdir ;
@@ -123,49 +122,12 @@ static int parse_pack_def(const char *line, int old_cnt)
123122 return 0 ;
124123 }
125124 else {
126- /* The file describes a pack that is no longer here;
127- * dependencies between packs needs to be recalculated.
128- */
125+ /* The file describes a pack that is no longer here */
129126 return 1 ;
130127 }
131128}
132129
133- /* Returns non-zero when we detect that the info in the
134- * old file is useless.
135- */
136- static int parse_depend_def (char * line )
137- {
138- unsigned long num ;
139- char * cp , * ep ;
140- struct pack_info * this , * that ;
141-
142- cp = line + 2 ;
143- num = strtoul (cp , & ep , 10 );
144- if (ep == cp )
145- return error ("invalid input %s" , line );
146- this = find_pack_by_old_num (num );
147- if (!this )
148- return 0 ;
149- while (ep && * (cp = ep )) {
150- num = strtoul (cp , & ep , 10 );
151- if (ep == cp )
152- break ;
153- that = find_pack_by_old_num (num );
154- if (!that )
155- /* The pack this one depends on does not
156- * exist; this should not happen because
157- * we write out the list of packs first and
158- * then dependency information, but it means
159- * the file is useless anyway.
160- */
161- return 1 ;
162- this -> dep [that -> new_num ] = 1 ;
163- }
164- return 0 ;
165- }
166-
167- /* Returns non-zero when we detect that the info in the
168- * old file is useless.
130+ /* Returns non-zero when we detect that the info in the old file is useless.
169131 */
170132static int parse_head_def (char * line )
171133{
@@ -212,9 +174,8 @@ static int read_pack_info_file(const char *infofile)
212174 if (parse_pack_def (line , old_cnt ++ ))
213175 goto out_stale ;
214176 break ;
215- case 'D' : /* D ix dep-ix1 dep-ix2... */
216- if (parse_depend_def (line ))
217- goto out_stale ;
177+ case 'D' : /* we used to emit D but that was misguided. */
178+ goto out_stale ;
218179 break ;
219180 case 'T' : /* T ix sha1 type */
220181 if (parse_head_def (line ))
@@ -286,7 +247,6 @@ static void init_pack_info(const char *infofile, int force)
286247 struct packed_git * p ;
287248 int stale ;
288249 int i = 0 ;
289- char * dep_temp ;
290250
291251 objdir = get_object_directory ();
292252 objdirlen = strlen (objdir );
@@ -307,7 +267,7 @@ static void init_pack_info(const char *infofile, int force)
307267 if (strncmp (p -> pack_name , objdir , objdirlen ) ||
308268 p -> pack_name [objdirlen ] != '/' )
309269 continue ;
310- info [i ] = xcalloc (1 , sizeof (struct pack_info ) + num_pack );
270+ info [i ] = xcalloc (1 , sizeof (struct pack_info ));
311271 info [i ]-> p = p ;
312272 info [i ]-> old_num = -1 ;
313273 i ++ ;
@@ -321,59 +281,23 @@ static void init_pack_info(const char *infofile, int force)
321281 for (i = 0 ; i < num_pack ; i ++ ) {
322282 if (stale ) {
323283 info [i ]-> old_num = -1 ;
324- memset (info [i ]-> dep , 0 , num_pack );
325284 info [i ]-> nr_heads = 0 ;
326285 }
327286 if (info [i ]-> old_num < 0 )
328287 info [i ]-> latest = get_latest_commit_date (info [i ]-> p );
329288 }
330289
290+ /* renumber them */
331291 qsort (info , num_pack , sizeof (info [0 ]), compare_info );
332292 for (i = 0 ; i < num_pack ; i ++ )
333293 info [i ]-> new_num = i ;
334-
335- /* we need to fix up the dependency information
336- * for the old ones.
337- */
338- dep_temp = NULL ;
339- for (i = 0 ; i < num_pack ; i ++ ) {
340- int old ;
341-
342- if (info [i ]-> old_num < 0 )
343- continue ;
344- if (! dep_temp )
345- dep_temp = xmalloc (num_pack );
346- memset (dep_temp , 0 , num_pack );
347- for (old = 0 ; old < num_pack ; old ++ ) {
348- struct pack_info * base ;
349- if (!info [i ]-> dep [old ])
350- continue ;
351- base = find_pack_by_old_num (old );
352- if (!base )
353- die ("internal error renumbering" );
354- dep_temp [base -> new_num ] = 1 ;
355- }
356- memcpy (info [i ]-> dep , dep_temp , num_pack );
357- }
358- free (dep_temp );
359294}
360295
361296static void write_pack_info_file (FILE * fp )
362297{
363298 int i , j ;
364299 for (i = 0 ; i < num_pack ; i ++ )
365300 fprintf (fp , "P %s\n" , info [i ]-> p -> pack_name + objdirlen + 6 );
366-
367- for (i = 0 ; i < num_pack ; i ++ ) {
368- fprintf (fp , "D %1d" , i );
369- for (j = 0 ; j < num_pack ; j ++ ) {
370- if ((i == j ) || !(info [i ]-> dep [j ]))
371- continue ;
372- fprintf (fp , " %1d" , j );
373- }
374- fputc ('\n' , fp );
375- }
376-
377301 for (i = 0 ; i < num_pack ; i ++ ) {
378302 struct pack_info * this = info [i ];
379303 for (j = 0 ; j < this -> nr_heads ; j ++ ) {
@@ -386,37 +310,18 @@ static void write_pack_info_file(FILE *fp)
386310}
387311
388312#define REFERENCED 01
389- #define INTERNAL 02
390313#define EMITTED 04
391314
392315static void show (struct object * o , int pack_ix )
393316{
394317 /*
395318 * We are interested in objects that are not referenced,
396- * and objects that are referenced but not internal.
397319 */
398320 if (o -> flags & EMITTED )
399321 return ;
400322
401323 if (!(o -> flags & REFERENCED ))
402324 add_head_def (info [pack_ix ], o -> sha1 );
403- else if ((o -> flags & REFERENCED ) && !(o -> flags & INTERNAL )) {
404- int i ;
405-
406- /* Which pack contains this object? That is what
407- * pack_ix can depend on. We earlier sorted info
408- * array from youngest to oldest, so try newer packs
409- * first to favor them here.
410- */
411- for (i = num_pack - 1 ; 0 <= i ; i -- ) {
412- struct packed_git * p = info [i ]-> p ;
413- struct pack_entry ent ;
414- if (find_pack_entry_one (o -> sha1 , & ent , p )) {
415- info [pack_ix ]-> dep [i ] = 1 ;
416- break ;
417- }
418- }
419- }
420325 o -> flags |= EMITTED ;
421326}
422327
@@ -445,7 +350,7 @@ static void find_pack_info_one(int pack_ix)
445350 o -> flags = 0 ;
446351 }
447352
448- /* Mark all the internal ones */
353+ /* Mark all the referenced ones */
449354 for (i = 0 ; i < num ; i ++ ) {
450355 if (nth_packed_object_sha1 (p , i , sha1 ))
451356 die ("corrupt pack file %s?" , p -> pack_name );
@@ -457,22 +362,14 @@ static void find_pack_info_one(int pack_ix)
457362 for (j = 0 ; j < refs -> count ; j ++ )
458363 refs -> ref [j ]-> flags |= REFERENCED ;
459364 }
460- o -> flags |= INTERNAL ;
461365 }
462366
463367 for (i = 0 ; i < num ; i ++ ) {
464368 if (nth_packed_object_sha1 (p , i , sha1 ))
465369 die ("corrupt pack file %s?" , p -> pack_name );
466370 if ((o = lookup_object (sha1 )) == NULL )
467371 die ("cannot find %s" , sha1_to_hex (sha1 ));
468-
469372 show (o , pack_ix );
470- if (o -> refs ) {
471- struct object_refs * refs = o -> refs ;
472- int j ;
473- for (j = 0 ; j < refs -> count ; j ++ )
474- show (refs -> ref [j ], pack_ix );
475- }
476373 }
477374
478375}
@@ -530,5 +427,8 @@ int update_server_info(int force)
530427 errs = errs | update_info_refs (force );
531428 errs = errs | update_info_packs (force );
532429
430+ /* remove leftover rev-cache file if there is any */
431+ unlink (git_path ("info/rev-cache" ));
432+
533433 return errs ;
534434}
0 commit comments