}
static char *sha1_get_pack_name(const unsigned char *sha1,
- char **name, char **base)
+ char **name, char **base, const char *which)
{
static const char hex[] = "0123456789abcdef";
char *buf;
const char *sha1_file_directory = get_object_directory();
int len = strlen(sha1_file_directory);
*base = xmalloc(len + 60);
- sprintf(*base, "%s/pack/pack-1234567890123456789012345678901234567890.pack", sha1_file_directory);
+ sprintf(*base, "%s/pack/pack-1234567890123456789012345678901234567890.%s",
+ sha1_file_directory, which);
*name = *base + len + 11;
}
{
static char *name, *base;
- return sha1_get_pack_name(sha1, &name, &base);
+ return sha1_get_pack_name(sha1, &name, &base, "pack");
}
char *sha1_pack_index_name(const unsigned char *sha1)
{
static char *name, *base;
- return sha1_get_pack_name(sha1, &name, &base);
+ return sha1_get_pack_name(sha1, &name, &base, "idx");
}
struct alternate_object_database *alt_odb_list;
munmap(map, mapsz);
}
+void add_to_alternates_file(const char *reference)
+{
+ struct lock_file *lock = xcalloc(1, sizeof(struct lock_file));
+ int fd = hold_lock_file_for_append(lock, git_path("objects/info/alternates"), 1);
+ char *alt = mkpath("%s/objects\n", reference);
+ write_or_die(fd, alt, strlen(alt));
+ if (commit_lock_file(lock))
+ die("could not close alternates file");
+ if (alt_odb_tail)
+ link_alt_odb_entries(alt, alt + strlen(alt), '\n', NULL, 0);
+}
+
void prepare_alt_odb(void)
{
const char *alt;