| 868 | } |
| 869 | |
| 870 | int odb_count_objects(struct object_database *odb, |
| 871 | enum odb_count_objects_flags flags, |
| 872 | unsigned long *out) |
| 873 | { |
| 874 | struct odb_source *source; |
| 875 | unsigned long count = 0; |
| 876 | int ret; |
| 877 | |
| 878 | if (odb->object_count_valid && odb->object_count_flags == flags) { |
| 879 | *out = odb->object_count; |
| 880 | return 0; |
| 881 | } |
| 882 | |
| 883 | odb_prepare_alternates(odb); |
| 884 | for (source = odb->sources; source; source = source->next) { |
| 885 | unsigned long c; |
| 886 | |
| 887 | ret = odb_source_count_objects(source, flags, &c); |
| 888 | if (ret < 0) |
| 889 | goto out; |
| 890 | |
| 891 | count += c; |
| 892 | } |
| 893 | |
| 894 | odb->object_count = count; |
| 895 | odb->object_count_valid = 1; |
| 896 | odb->object_count_flags = flags; |
| 897 | |
| 898 | *out = count; |
| 899 | ret = 0; |
| 900 | |
| 901 | out: |
| 902 | return ret; |
| 903 | } |
| 904 | |
| 905 | /* |
| 906 | * Return the slot of the most-significant bit set in "val". There are various |
no test coverage detected