@@ -506,7 +506,8 @@ static int should_include(struct commit *commit, void *_data)
506
506
static struct bitmap * find_objects (struct bitmap_index * bitmap_git ,
507
507
struct rev_info * revs ,
508
508
struct object_list * roots ,
509
- struct bitmap * seen )
509
+ struct bitmap * seen ,
510
+ struct list_objects_filter_options * filter )
510
511
{
511
512
struct bitmap * base = NULL ;
512
513
int needs_walk = 0 ;
@@ -599,8 +600,9 @@ static struct bitmap *find_objects(struct bitmap_index *bitmap_git,
599
600
show_data .bitmap_git = bitmap_git ;
600
601
show_data .base = base ;
601
602
602
- traverse_commit_list (revs , show_commit , show_object ,
603
- & show_data );
603
+ traverse_commit_list_filtered (filter , revs ,
604
+ show_commit , show_object ,
605
+ & show_data , NULL );
604
606
}
605
607
606
608
return base ;
@@ -715,16 +717,17 @@ static int in_bitmapped_pack(struct bitmap_index *bitmap_git,
715
717
return 0 ;
716
718
}
717
719
718
- static struct bitmap * find_tip_blobs (struct bitmap_index * bitmap_git ,
719
- struct object_list * tip_objects )
720
+ static struct bitmap * find_tip_objects (struct bitmap_index * bitmap_git ,
721
+ struct object_list * tip_objects ,
722
+ enum object_type type )
720
723
{
721
724
struct bitmap * result = bitmap_new ();
722
725
struct object_list * p ;
723
726
724
727
for (p = tip_objects ; p ; p = p -> next ) {
725
728
int pos ;
726
729
727
- if (p -> item -> type != OBJ_BLOB )
730
+ if (p -> item -> type != type )
728
731
continue ;
729
732
730
733
pos = bitmap_position (bitmap_git , & p -> item -> oid );
@@ -737,28 +740,32 @@ static struct bitmap *find_tip_blobs(struct bitmap_index *bitmap_git,
737
740
return result ;
738
741
}
739
742
740
- static void filter_bitmap_blob_none (struct bitmap_index * bitmap_git ,
741
- struct object_list * tip_objects ,
742
- struct bitmap * to_filter )
743
+ static void filter_bitmap_exclude_type (struct bitmap_index * bitmap_git ,
744
+ struct object_list * tip_objects ,
745
+ struct bitmap * to_filter ,
746
+ enum object_type type )
743
747
{
744
748
struct eindex * eindex = & bitmap_git -> ext_index ;
745
749
struct bitmap * tips ;
746
750
struct ewah_iterator it ;
747
751
eword_t mask ;
748
752
uint32_t i ;
749
753
754
+ if (type != OBJ_BLOB && type != OBJ_TREE )
755
+ BUG ("filter_bitmap_exclude_type: unsupported type '%d'" , type );
756
+
750
757
/*
751
758
* The non-bitmap version of this filter never removes
752
- * blobs which the other side specifically asked for,
759
+ * objects which the other side specifically asked for,
753
760
* so we must match that behavior.
754
761
*/
755
- tips = find_tip_blobs (bitmap_git , tip_objects );
762
+ tips = find_tip_objects (bitmap_git , tip_objects , type );
756
763
757
764
/*
758
765
* We can use the blob type-bitmap to work in whole words
759
766
* for the objects that are actually in the bitmapped packfile.
760
767
*/
761
- for (i = 0 , init_type_iterator (& it , bitmap_git , OBJ_BLOB );
768
+ for (i = 0 , init_type_iterator (& it , bitmap_git , type );
762
769
i < to_filter -> word_alloc && ewah_iterator_next (& mask , & it );
763
770
i ++ ) {
764
771
if (i < tips -> word_alloc )
@@ -773,7 +780,7 @@ static void filter_bitmap_blob_none(struct bitmap_index *bitmap_git,
773
780
*/
774
781
for (i = 0 ; i < eindex -> count ; i ++ ) {
775
782
uint32_t pos = i + bitmap_git -> pack -> num_objects ;
776
- if (eindex -> objects [i ]-> type == OBJ_BLOB &&
783
+ if (eindex -> objects [i ]-> type == type &&
777
784
bitmap_get (to_filter , pos ) &&
778
785
!bitmap_get (tips , pos ))
779
786
bitmap_unset (to_filter , pos );
@@ -782,6 +789,14 @@ static void filter_bitmap_blob_none(struct bitmap_index *bitmap_git,
782
789
bitmap_free (tips );
783
790
}
784
791
792
+ static void filter_bitmap_blob_none (struct bitmap_index * bitmap_git ,
793
+ struct object_list * tip_objects ,
794
+ struct bitmap * to_filter )
795
+ {
796
+ filter_bitmap_exclude_type (bitmap_git , tip_objects , to_filter ,
797
+ OBJ_BLOB );
798
+ }
799
+
785
800
static unsigned long get_size_by_pos (struct bitmap_index * bitmap_git ,
786
801
uint32_t pos )
787
802
{
@@ -820,7 +835,7 @@ static void filter_bitmap_blob_limit(struct bitmap_index *bitmap_git,
820
835
eword_t mask ;
821
836
uint32_t i ;
822
837
823
- tips = find_tip_blobs (bitmap_git , tip_objects );
838
+ tips = find_tip_objects (bitmap_git , tip_objects , OBJ_BLOB );
824
839
825
840
for (i = 0 , init_type_iterator (& it , bitmap_git , OBJ_BLOB );
826
841
i < to_filter -> word_alloc && ewah_iterator_next (& mask , & it );
@@ -854,6 +869,20 @@ static void filter_bitmap_blob_limit(struct bitmap_index *bitmap_git,
854
869
bitmap_free (tips );
855
870
}
856
871
872
+ static void filter_bitmap_tree_depth (struct bitmap_index * bitmap_git ,
873
+ struct object_list * tip_objects ,
874
+ struct bitmap * to_filter ,
875
+ unsigned long limit )
876
+ {
877
+ if (limit )
878
+ BUG ("filter_bitmap_tree_depth given non-zero limit" );
879
+
880
+ filter_bitmap_exclude_type (bitmap_git , tip_objects , to_filter ,
881
+ OBJ_TREE );
882
+ filter_bitmap_exclude_type (bitmap_git , tip_objects , to_filter ,
883
+ OBJ_BLOB );
884
+ }
885
+
857
886
static int filter_bitmap (struct bitmap_index * bitmap_git ,
858
887
struct object_list * tip_objects ,
859
888
struct bitmap * to_filter ,
@@ -877,6 +906,15 @@ static int filter_bitmap(struct bitmap_index *bitmap_git,
877
906
return 0 ;
878
907
}
879
908
909
+ if (filter -> choice == LOFC_TREE_DEPTH &&
910
+ filter -> tree_exclude_depth == 0 ) {
911
+ if (bitmap_git )
912
+ filter_bitmap_tree_depth (bitmap_git , tip_objects ,
913
+ to_filter ,
914
+ filter -> tree_exclude_depth );
915
+ return 0 ;
916
+ }
917
+
880
918
/* filter choice not handled */
881
919
return -1 ;
882
920
}
@@ -963,15 +1001,17 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs,
963
1001
964
1002
if (haves ) {
965
1003
revs -> ignore_missing_links = 1 ;
966
- haves_bitmap = find_objects (bitmap_git , revs , haves , NULL );
1004
+ haves_bitmap = find_objects (bitmap_git , revs , haves , NULL ,
1005
+ filter );
967
1006
reset_revision_walk ();
968
1007
revs -> ignore_missing_links = 0 ;
969
1008
970
1009
if (haves_bitmap == NULL )
971
1010
BUG ("failed to perform bitmap walk" );
972
1011
}
973
1012
974
- wants_bitmap = find_objects (bitmap_git , revs , wants , haves_bitmap );
1013
+ wants_bitmap = find_objects (bitmap_git , revs , wants , haves_bitmap ,
1014
+ filter );
975
1015
976
1016
if (!wants_bitmap )
977
1017
BUG ("failed to perform bitmap walk" );
0 commit comments