#include "pack-revindex.h"
#include "sha1-lookup.h"
#include "bulk-checkin.h"
+#include "repository.h"
#include "streaming.h"
#include "dir.h"
#include "list.h"
#include "quote.h"
#include "packfile.h"
#include "fetch-object.h"
+#include "object-store.h"
const unsigned char null_sha1[GIT_MAX_RAWSZ];
const struct object_id null_oid;
return buf->buf;
}
-struct alternate_object_database *alt_odb_list;
-static struct alternate_object_database **alt_odb_tail;
-
/*
* Return non-zero iff the path is usable as an alternate object database.
*/
-static int alt_odb_usable(struct strbuf *path, const char *normalized_objdir)
+static int alt_odb_usable(struct raw_object_store *o,
+ struct strbuf *path,
+ const char *normalized_objdir)
{
struct alternate_object_database *alt;
* Prevent the common mistake of listing the same
* thing twice, or object directory itself.
*/
- for (alt = alt_odb_list; alt; alt = alt->next) {
+ for (alt = o->alt_odb_list; alt; alt = alt->next) {
if (!fspathcmp(path->buf, alt->path))
return 0;
}
* terminating NUL.
*/
static void read_info_alternates(const char * relative_base, int depth);
-static int link_alt_odb_entry(const char *entry, const char *relative_base,
- int depth, const char *normalized_objdir)
+#define link_alt_odb_entry(r, e, rb, d, n) link_alt_odb_entry_##r(e, rb, d, n)
+static int link_alt_odb_entry_the_repository(const char *entry,
+ const char *relative_base, int depth, const char *normalized_objdir)
{
struct alternate_object_database *ent;
struct strbuf pathbuf = STRBUF_INIT;
while (pathbuf.len && pathbuf.buf[pathbuf.len - 1] == '/')
strbuf_setlen(&pathbuf, pathbuf.len - 1);
- if (!alt_odb_usable(&pathbuf, normalized_objdir)) {
+ if (!alt_odb_usable(the_repository->objects, &pathbuf, normalized_objdir)) {
strbuf_release(&pathbuf);
return -1;
}
ent = alloc_alt_odb(pathbuf.buf);
/* add the alternate entry */
- *alt_odb_tail = ent;
- alt_odb_tail = &(ent->next);
+ *the_repository->objects->alt_odb_tail = ent;
+ the_repository->objects->alt_odb_tail = &(ent->next);
ent->next = NULL;
/* recursively add alternates */
alt = parse_alt_odb_entry(alt, sep, &entry);
if (!entry.len)
continue;
- link_alt_odb_entry(entry.buf, relative_base, depth, objdirbuf.buf);
+ link_alt_odb_entry(the_repository, entry.buf,
+ relative_base, depth, objdirbuf.buf);
}
strbuf_release(&entry);
strbuf_release(&objdirbuf);
fprintf_or_die(out, "%s\n", reference);
if (commit_lock_file(&lock))
die_errno("unable to move new alternates file into place");
- if (alt_odb_tail)
+ if (the_repository->objects->alt_odb_tail)
link_alt_odb_entries(reference, '\n', NULL, 0);
}
free(alts);
int r = 0;
prepare_alt_odb();
- for (ent = alt_odb_list; ent; ent = ent->next) {
+ for (ent = the_repository->objects->alt_odb_list; ent; ent = ent->next) {
r = fn(ent, cb);
if (r)
break;
void prepare_alt_odb(void)
{
- const char *alt;
-
- if (alt_odb_tail)
+ if (the_repository->objects->alt_odb_tail)
return;
- alt = getenv(ALTERNATE_DB_ENVIRONMENT);
-
- alt_odb_tail = &alt_odb_list;
- link_alt_odb_entries(alt, PATH_SEP, NULL, 0);
+ the_repository->objects->alt_odb_tail =
+ &the_repository->objects->alt_odb_list;
+ link_alt_odb_entries(the_repository->objects->alternate_db,
+ PATH_SEP, NULL, 0);
read_info_alternates(get_object_directory(), 0);
}
{
struct alternate_object_database *alt;
prepare_alt_odb();
- for (alt = alt_odb_list; alt; alt = alt->next) {
+ for (alt = the_repository->objects->alt_odb_list; alt; alt = alt->next) {
const char *path = alt_sha1_path(alt, sha1);
if (check_and_freshen_file(path, freshen))
return 1;
prepare_alt_odb();
errno = ENOENT;
- for (alt = alt_odb_list; alt; alt = alt->next) {
+ for (alt = the_repository->objects->alt_odb_list; alt; alt = alt->next) {
*path = alt_sha1_path(alt, sha1);
if (!lstat(*path, st))
return 0;
most_interesting_errno = errno;
prepare_alt_odb();
- for (alt = alt_odb_list; alt; alt = alt->next) {
+ for (alt = the_repository->objects->alt_odb_list; alt; alt = alt->next) {
*path = alt_sha1_path(alt, sha1);
fd = git_open(*path);
if (fd >= 0)