| 927 | } |
| 928 | |
| 929 | int force_object_loose(struct odb_source *source, |
| 930 | const struct object_id *oid, time_t mtime) |
| 931 | { |
| 932 | struct odb_source_files *files = odb_source_files_downcast(source); |
| 933 | const struct git_hash_algo *compat = source->odb->repo->compat_hash_algo; |
| 934 | void *buf; |
| 935 | size_t len; |
| 936 | struct object_info oi = OBJECT_INFO_INIT; |
| 937 | struct object_id compat_oid; |
| 938 | enum object_type type; |
| 939 | char hdr[MAX_HEADER_LEN]; |
| 940 | int hdrlen; |
| 941 | int ret; |
| 942 | |
| 943 | for (struct odb_source *s = source->odb->sources; s; s = s->next) { |
| 944 | struct odb_source_files *files = odb_source_files_downcast(s); |
| 945 | if (!odb_source_read_object_info(&files->loose->base, oid, NULL, 0)) |
| 946 | return 0; |
| 947 | } |
| 948 | |
| 949 | oi.typep = &type; |
| 950 | oi.sizep = &len; |
| 951 | oi.contentp = &buf; |
| 952 | if (odb_read_object_info_extended(source->odb, oid, &oi, 0)) |
| 953 | return error(_("cannot read object for %s"), oid_to_hex(oid)); |
| 954 | if (compat) { |
| 955 | if (repo_oid_to_algop(source->odb->repo, oid, compat, &compat_oid)) |
| 956 | return error(_("cannot map object %s to %s"), |
| 957 | oid_to_hex(oid), compat->name); |
| 958 | } |
| 959 | hdrlen = format_object_header(hdr, sizeof(hdr), type, len); |
| 960 | ret = write_loose_object(files->loose, oid, hdr, hdrlen, buf, len, mtime, 0); |
| 961 | if (!ret && compat) |
| 962 | ret = repo_add_loose_object_map(files->loose, oid, &compat_oid); |
| 963 | free(buf); |
| 964 | |
| 965 | return ret; |
| 966 | } |
| 967 | |
| 968 | /* |
| 969 | * We can't use the normal fsck_error_function() for index_mem(), |
no test coverage detected