712
return 0;
713
}
714
715
+static struct bitmap *find_tip_blobs(struct bitmap_index *bitmap_git,
716
+ struct object_list *tip_objects)
717
+{
718
+ struct bitmap *result = bitmap_new();
719
+ struct object_list *p;
720
+
721
+ for (p = tip_objects; p; p = p->next) {
722
+ int pos;
723
+
724
+ if (p->item->type != OBJ_BLOB)
725
+ continue;
726
+
727
+ pos = bitmap_position(bitmap_git, &p->item->oid);
728
+ if (pos < 0)
729
+ continue;
730
+
731
+ bitmap_set(result, pos);
732
+ }
733
+
734
+ return result;
735
+}
736
+
737
+static void filter_bitmap_blob_none(struct bitmap_index *bitmap_git,
738
+ struct object_list *tip_objects,
739
+ struct bitmap *to_filter)
740
+{
741
+ struct eindex *eindex = &bitmap_git->ext_index;
742
+ struct bitmap *tips;
743
+ struct ewah_iterator it;
744
+ eword_t mask;
745
+ uint32_t i;
746
+
747
+ /*
748
+ * The non-bitmap version of this filter never removes
749
+ * blobs which the other side specifically asked for,
750
+ * so we must match that behavior.
751
+ */
752
+ tips = find_tip_blobs(bitmap_git, tip_objects);
753
+
754
+ /*
755
+ * We can use the blob type-bitmap to work in whole words
756
+ * for the objects that are actually in the bitmapped packfile.
757
+ */
758
+ for (i = 0, init_type_iterator(&it, bitmap_git, OBJ_BLOB);
759
+ i < to_filter->word_alloc && ewah_iterator_next(&mask, &it);
760
+ i++) {
761
+ if (i < tips->word_alloc)
762
+ mask &= ~tips->words[i];
763
+ to_filter->words[i] &= ~mask;
764
+ }
765
+
766
+ /*
767
+ * Clear any blobs that weren't in the packfile (and so would not have
768
+ * been caught by the loop above. We'll have to check them
769
+ * individually.
770
+ */
771
+ for (i = 0; i < eindex->count; i++) {
772
+ uint32_t pos = i + bitmap_git->pack->num_objects;
773
+ if (eindex->objects[i]->type == OBJ_BLOB &&
774
+ bitmap_get(to_filter, pos) &&
775
+ !bitmap_get(tips, pos))
776
+ bitmap_unset(to_filter, pos);
777
+ }
778
+
779
+ bitmap_free(tips);
780
+}
781
+
782
static int filter_bitmap(struct bitmap_index *bitmap_git,
783
struct object_list *tip_objects,
784
struct bitmap *to_filter,
787
if (!filter || filter->choice == LOFC_DISABLED)
788
return 0;
789
790
+ if (filter->choice == LOFC_BLOB_NONE) {
791
+ if (bitmap_git)
792
+ filter_bitmap_blob_none(bitmap_git, tip_objects,
793
+ to_filter);
794
+ return 0;
795
+ }
796
+
797
/* filter choice not handled */
798
return -1;
799
}