#include "list.h"
#include "packfile.h"
#include "object-file.h"
+#include "object-file-convert.h"
#include "odb.h"
#include "odb/streaming.h"
#include "replace-object.h"
return 1;
}
+static int force_object_loose(struct odb_source *source,
+ const struct object_id *oid,
+ const time_t *mtime)
+{
+ struct odb_source_files *files = odb_source_files_downcast(source);
+ const struct git_hash_algo *compat = source->odb->repo->compat_hash_algo;
+ struct object_info oi = OBJECT_INFO_INIT;
+ struct object_id compat_oid, *compat_oid_p = NULL;
+ enum object_type type;
+ void *buf = NULL;
+ size_t len;
+ int ret;
+
+ for (struct odb_source *s = source->odb->sources; s; s = s->next) {
+ struct odb_source_files *files = odb_source_files_downcast(s);
+ if (!odb_source_read_object_info(&files->loose->base, oid, NULL, 0))
+ return 0;
+ }
+
+ oi.typep = &type;
+ oi.sizep = &len;
+ oi.contentp = &buf;
+ if (odb_read_object_info_extended(source->odb, oid, &oi, 0)) {
+ ret = error(_("cannot read object for %s"), oid_to_hex(oid));
+ goto out;
+ }
+
+ if (compat) {
+ if (repo_oid_to_algop(source->odb->repo, oid, compat, &compat_oid)) {
+ ret = error(_("cannot map object %s to %s"),
+ oid_to_hex(oid), compat->name);
+ goto out;
+ }
+
+ compat_oid_p = &compat_oid;
+ }
+
+ ret = odb_source_write_object(&files->loose->base, buf, len, type, oid,
+ compat_oid_p, mtime, 0);
+
+out:
+ free(buf);
+ return ret;
+}
+
static void loosen_unused_packed_objects(void)
{
struct packed_git *p;
return err;
}
-int force_object_loose(struct odb_source *source,
- const struct object_id *oid, const time_t *mtime)
-{
- struct odb_source_files *files = odb_source_files_downcast(source);
- const struct git_hash_algo *compat = source->odb->repo->compat_hash_algo;
- struct object_info oi = OBJECT_INFO_INIT;
- struct object_id compat_oid, *compat_oid_p = NULL;
- enum object_type type;
- void *buf = NULL;
- size_t len;
- int ret;
-
- for (struct odb_source *s = source->odb->sources; s; s = s->next) {
- struct odb_source_files *files = odb_source_files_downcast(s);
- if (!odb_source_read_object_info(&files->loose->base, oid, NULL, 0))
- return 0;
- }
-
- oi.typep = &type;
- oi.sizep = &len;
- oi.contentp = &buf;
- if (odb_read_object_info_extended(source->odb, oid, &oi, 0)) {
- ret = error(_("cannot read object for %s"), oid_to_hex(oid));
- goto out;
- }
-
- if (compat) {
- if (repo_oid_to_algop(source->odb->repo, oid, compat, &compat_oid)) {
- ret = error(_("cannot map object %s to %s"),
- oid_to_hex(oid), compat->name);
- goto out;
- }
-
- compat_oid_p = &compat_oid;
- }
-
- ret = odb_source_write_object(&files->loose->base, buf, len, type, oid,
- compat_oid_p, mtime, 0);
-
-out:
- free(buf);
- return ret;
-}
-
/*
* We can't use the normal fsck_error_function() for index_mem(),
* because we don't yet have a valid oid for it to report. Instead,
int format_object_header(char *str, size_t size, enum object_type type,
size_t objsize);
-int force_object_loose(struct odb_source *source,
- const struct object_id *oid,
- const time_t *mtime);
-
/**
* With in-core object data in "buf", rehash it to make sure the
* object name actually matches "oid" to detect object corruption.