@@ -667,48 +667,15 @@ static void add_family_to_write_order(struct object_entry **wo,
667
667
add_descendants_to_write_order (wo , endp , root );
668
668
}
669
669
670
- static struct object_entry * * compute_write_order ( void )
670
+ static void compute_layer_order ( struct object_entry * * wo , unsigned int * wo_end )
671
671
{
672
- unsigned int i , wo_end , last_untagged ;
673
-
674
- struct object_entry * * wo ;
672
+ unsigned int i , last_untagged ;
675
673
struct object_entry * objects = to_pack .objects ;
676
674
677
675
for (i = 0 ; i < to_pack .nr_objects ; i ++ ) {
678
- objects [i ].tagged = 0 ;
679
- objects [i ].filled = 0 ;
680
- SET_DELTA_CHILD (& objects [i ], NULL );
681
- SET_DELTA_SIBLING (& objects [i ], NULL );
682
- }
683
-
684
- /*
685
- * Fully connect delta_child/delta_sibling network.
686
- * Make sure delta_sibling is sorted in the original
687
- * recency order.
688
- */
689
- for (i = to_pack .nr_objects ; i > 0 ;) {
690
- struct object_entry * e = & objects [-- i ];
691
- if (!DELTA (e ))
692
- continue ;
693
- /* Mark me as the first child */
694
- e -> delta_sibling_idx = DELTA (e )-> delta_child_idx ;
695
- SET_DELTA_CHILD (DELTA (e ), e );
696
- }
697
-
698
- /*
699
- * Mark objects that are at the tip of tags.
700
- */
701
- for_each_tag_ref (mark_tagged , NULL );
702
-
703
- /*
704
- * Give the objects in the original recency order until
705
- * we see a tagged tip.
706
- */
707
- ALLOC_ARRAY (wo , to_pack .nr_objects );
708
- for (i = wo_end = 0 ; i < to_pack .nr_objects ; i ++ ) {
709
676
if (objects [i ].tagged )
710
677
break ;
711
- add_to_write_order (wo , & wo_end , & objects [i ]);
678
+ add_to_write_order (wo , wo_end , & objects [i ]);
712
679
}
713
680
last_untagged = i ;
714
681
@@ -717,7 +684,7 @@ static struct object_entry **compute_write_order(void)
717
684
*/
718
685
for (; i < to_pack .nr_objects ; i ++ ) {
719
686
if (objects [i ].tagged )
720
- add_to_write_order (wo , & wo_end , & objects [i ]);
687
+ add_to_write_order (wo , wo_end , & objects [i ]);
721
688
}
722
689
723
690
/*
@@ -727,7 +694,7 @@ static struct object_entry **compute_write_order(void)
727
694
if (oe_type (& objects [i ]) != OBJ_COMMIT &&
728
695
oe_type (& objects [i ]) != OBJ_TAG )
729
696
continue ;
730
- add_to_write_order (wo , & wo_end , & objects [i ]);
697
+ add_to_write_order (wo , wo_end , & objects [i ]);
731
698
}
732
699
733
700
/*
@@ -736,16 +703,59 @@ static struct object_entry **compute_write_order(void)
736
703
for (i = last_untagged ; i < to_pack .nr_objects ; i ++ ) {
737
704
if (oe_type (& objects [i ]) != OBJ_TREE )
738
705
continue ;
739
- add_to_write_order (wo , & wo_end , & objects [i ]);
706
+ add_to_write_order (wo , wo_end , & objects [i ]);
740
707
}
741
708
742
709
/*
743
710
* Finally all the rest in really tight order
744
711
*/
745
712
for (i = last_untagged ; i < to_pack .nr_objects ; i ++ ) {
746
713
if (!objects [i ].filled )
747
- add_family_to_write_order (wo , & wo_end , & objects [i ]);
714
+ add_family_to_write_order (wo , wo_end , & objects [i ]);
748
715
}
716
+ }
717
+
718
+ static struct object_entry * * compute_write_order (void )
719
+ {
720
+ unsigned int i , wo_end ;
721
+
722
+ struct object_entry * * wo ;
723
+ struct object_entry * objects = to_pack .objects ;
724
+
725
+ for (i = 0 ; i < to_pack .nr_objects ; i ++ ) {
726
+ objects [i ].tagged = 0 ;
727
+ objects [i ].filled = 0 ;
728
+ SET_DELTA_CHILD (& objects [i ], NULL );
729
+ SET_DELTA_SIBLING (& objects [i ], NULL );
730
+ }
731
+
732
+ /*
733
+ * Fully connect delta_child/delta_sibling network.
734
+ * Make sure delta_sibling is sorted in the original
735
+ * recency order.
736
+ */
737
+ for (i = to_pack .nr_objects ; i > 0 ;) {
738
+ struct object_entry * e = & objects [-- i ];
739
+ if (!DELTA (e ))
740
+ continue ;
741
+ /* Mark me as the first child */
742
+ e -> delta_sibling_idx = DELTA (e )-> delta_child_idx ;
743
+ SET_DELTA_CHILD (DELTA (e ), e );
744
+ }
745
+
746
+ /*
747
+ * Mark objects that are at the tip of tags.
748
+ */
749
+ for_each_tag_ref (mark_tagged , NULL );
750
+
751
+ /*
752
+ * Give the objects in the original recency order until
753
+ * we see a tagged tip.
754
+ */
755
+ ALLOC_ARRAY (wo , to_pack .nr_objects );
756
+ wo_end = 0 ;
757
+
758
+ compute_layer_order (wo , & wo_end );
749
759
750
760
if (wo_end != to_pack .nr_objects )
751
761
die ("ordered %u objects, expected %" PRIu32 , wo_end , to_pack .nr_objects );
0 commit comments