+5
-28
index 79e7ab8d2e..893c32adcd 100644
--- a/object-file.c
+++ b/object-file.c
FOF_SKIP_COLLISION_CHECK);
}
-static int freshen_loose_object(struct object_database *odb,
- const struct object_id *oid)
+int odb_source_loose_freshen_object(struct odb_source *source,
+ const struct object_id *oid)
{
- odb_prepare_alternates(odb);
- for (struct odb_source *source = odb->sources; source; source = source->next)
- if (check_and_freshen_source(source, oid, 1))
- return 1;
- return 0;
-}
-
-static int freshen_packed_object(struct object_database *odb,
- const struct object_id *oid)
-{
- struct pack_entry e;
- if (!find_pack_entry(odb->repo, oid, &e))
- return 0;
- if (e.p->is_cruft)
- return 0;
- if (e.p->freshened)
- return 1;
- if (!freshen_file(e.p->pack_name))
- return 0;
- e.p->freshened = 1;
- return 1;
+ return !!check_and_freshen_source(source, oid, 1);
}
int stream_loose_object(struct odb_source *source,
die(_("deflateEnd on stream object failed (%d)"), ret);
close_loose_object(source, fd, tmp_file.buf);
- if (freshen_packed_object(source->odb, oid) ||
- freshen_loose_object(source->odb, oid)) {
+ if (odb_freshen_object(source->odb, oid)) {
unlink_or_warn(tmp_file.buf);
goto cleanup;
}
-
odb_loose_path(source, &filename, oid);
/* We finally know the object path, and create the missing dir. */
* it out into .git/objects/??/?{38} file.
*/
write_object_file_prepare(algo, buf, len, type, oid, hdr, &hdrlen);
- if (freshen_packed_object(source->odb, oid) ||
- freshen_loose_object(source->odb, oid))
+ if (odb_freshen_object(source->odb, oid))
return 0;
if (write_loose_object(source, oid, hdr, hdrlen, buf, len, 0, flags))
return -1;
+3
index 065a44bb8a..ee5b24cec6 100644
--- a/object-file.h
+++ b/object-file.h
int odb_source_loose_has_object(struct odb_source *source,
const struct object_id *oid);
+int odb_source_loose_freshen_object(struct odb_source *source,
+ const struct object_id *oid);
+
/*
* Populate and return the loose object cache array corresponding to the
* given object ID.
+16
index 4c0b4fdcd5..17734bdaff 100644
--- a/odb.c
+++ b/odb.c
return odb_read_object_info_extended(odb, oid, NULL, object_info_flags) >= 0;
}
+int odb_freshen_object(struct object_database *odb,
+ const struct object_id *oid)
+{
+ struct odb_source *source;
+
+ if (packfile_store_freshen_object(odb->packfiles, oid))
+ return 1;
+
+ odb_prepare_alternates(odb);
+ for (source = odb->sources; source; source = source->next)
+ if (odb_source_loose_freshen_object(source, oid))
+ return 1;
+
+ return 0;
+}
+
void odb_assert_oid_type(struct object_database *odb,
const struct object_id *oid, enum object_type expect)
{
+3
index f9a3137a34..2653247e0c 100644
--- a/odb.h
+++ b/odb.h
const struct object_id *oid,
unsigned flags);
+int odb_freshen_object(struct object_database *odb,
+ const struct object_id *oid);
+
void odb_assert_oid_type(struct object_database *odb,
const struct object_id *oid, enum object_type expect);
+16
index 1ae2b2fe1e..40f733dd23 100644
--- a/packfile.c
+++ b/packfile.c
return p;
}
+int packfile_store_freshen_object(struct packfile_store *store,
+ const struct object_id *oid)
+{
+ struct pack_entry e;
+ if (!find_pack_entry(store->odb->repo, oid, &e))
+ return 0;
+ if (e.p->is_cruft)
+ return 0;
+ if (e.p->freshened)
+ return 1;
+ if (utime(e.p->pack_name, NULL))
+ return 0;
+ e.p->freshened = 1;
+ return 1;
+}
+
void (*report_garbage)(unsigned seen_bits, const char *path);
static void report_helper(const struct string_list *list,
+3
index c9d0b93446..58fcc88e20 100644
--- a/packfile.h
+++ b/packfile.h
struct packed_git *packfile_store_load_pack(struct packfile_store *store,
const char *idx_path, int local);
+int packfile_store_freshen_object(struct packfile_store *store,
+ const struct object_id *oid);
+
struct pack_window {
struct pack_window *next;
unsigned char *base;