#include "tree.h"
#include "object-store.h"
#include "midx.h"
+#include "commit-graph.h"
+#include "promisor-remote.h"
char *odb_pack_name(struct strbuf *buf,
const unsigned char *sha1,
return 0;
}
-void release_pack_memory(size_t need)
-{
- size_t cur = pack_mapped;
- while (need >= (cur - pack_mapped) && unuse_one_window(NULL))
- ; /* nothing */
-}
-
void close_pack_windows(struct packed_git *p)
{
while (p->windows) {
close_pack_index(p);
}
-void close_all_packs(struct raw_object_store *o)
+void close_object_store(struct raw_object_store *o)
{
struct packed_git *p;
close_midx(o->multi_pack_index);
o->multi_pack_index = NULL;
}
+
+ close_commit_graph(o);
+}
+
+void unlink_pack_path(const char *pack_name, int force_delete)
+{
+ static const char *exts[] = {".pack", ".idx", ".keep", ".bitmap", ".promisor"};
+ int i;
+ struct strbuf buf = STRBUF_INIT;
+ size_t plen;
+
+ strbuf_addstr(&buf, pack_name);
+ strip_suffix_mem(buf.buf, &buf.len, ".pack");
+ plen = buf.len;
+
+ if (!force_delete) {
+ strbuf_addstr(&buf, ".keep");
+ if (!access(buf.buf, F_OK)) {
+ strbuf_release(&buf);
+ return;
+ }
+ }
+
+ for (i = 0; i < ARRAY_SIZE(exts); i++) {
+ strbuf_setlen(&buf, plen);
+ strbuf_addstr(&buf, exts[i]);
+ unlink(buf.buf);
+ }
+
+ strbuf_release(&buf);
}
/*
}
}
-static void try_to_free_pack_memory(size_t size)
-{
- release_pack_memory(size);
-}
-
struct packed_git *add_packed_git(const char *path, size_t path_len, int local)
{
- static int have_set_try_to_free_routine;
struct stat st;
size_t alloc;
struct packed_git *p;
- if (!have_set_try_to_free_routine) {
- have_set_try_to_free_routine = 1;
- set_try_to_free_routine(try_to_free_pack_memory);
- }
-
/*
* Make sure a corresponding .pack file exists and that
* the index looks sane.
oidset_insert(set, &parents->item->object.oid);
} else if (obj->type == OBJ_TAG) {
struct tag *tag = (struct tag *) obj;
- oidset_insert(set, &tag->tagged->oid);
+ oidset_insert(set, get_tagged_oid(tag));
}
return 0;
}
static int promisor_objects_prepared;
if (!promisor_objects_prepared) {
- if (repository_format_partial_clone) {
+ if (has_promisor_remote()) {
for_each_packed_object(add_promisor_object,
&promisor_objects,
FOR_EACH_OBJECT_PROMISOR_ONLY);