Merge branch 'ps/odb-stop-registering-in-memory-sources' into jch
The mechanism to register in-memory alternate object sources has been removed, as submodule object databases are now accessed natively via their own repository structures. This simplifies object database management and prepares the codebase for migrating alternate tracking into the files backend. * ps/odb-stop-registering-in-memory-sources: odb: remove the ability to link sources ad-hoc t/helper: stop registering alternates in "ref-store" command t/helper: adapt read-midx to not link ad-hoc source anymore builtin/multi-pack-index: refuse unknown sources with "--object-dir=" odb/packed: fix memory leaks when freeing source tmp-objdir: drop unused function to register alternate odb: remove infrastructure to register submodule sources builtin/grep: stop registering submodule ODB as source submodule-config: stop registering submodule sources submodule-config: stop using `the_hash_algo` submodule-config: remove uses of `the_repository` cache-tree: remove dependency on `the_repository`jch
commit
11a064e7ed
|
|
@ -921,7 +921,7 @@ static int merge_working_tree(const struct checkout_opts *opts,
|
|||
}
|
||||
}
|
||||
|
||||
if (!cache_tree_fully_valid(the_repository->index->cache_tree))
|
||||
if (!cache_tree_fully_valid(the_repository, the_repository->index->cache_tree))
|
||||
cache_tree_update(the_repository->index, WRITE_TREE_SILENT | WRITE_TREE_REPAIR);
|
||||
|
||||
if (write_locked_index(the_repository->index, &lock_file, COMMIT_LOCK))
|
||||
|
|
|
|||
|
|
@ -484,7 +484,7 @@ static const char *prepare_index(const char **argv, const char *prefix,
|
|||
LOCK_DIE_ON_ERROR);
|
||||
refresh_cache_or_die(refresh_flags);
|
||||
if (the_repository->index->cache_changed
|
||||
|| !cache_tree_fully_valid(the_repository->index->cache_tree))
|
||||
|| !cache_tree_fully_valid(the_repository, the_repository->index->cache_tree))
|
||||
cache_tree_update(the_repository->index, WRITE_TREE_SILENT);
|
||||
if (write_locked_index(the_repository->index, &index_lock,
|
||||
COMMIT_LOCK | SKIP_IF_UNCHANGED))
|
||||
|
|
|
|||
|
|
@ -2681,7 +2681,7 @@ int cmd_fetch(int argc,
|
|||
int *rs = config.recurse_submodules == RECURSE_SUBMODULES_DEFAULT
|
||||
? &config.recurse_submodules : NULL;
|
||||
|
||||
fetch_config_from_gitmodules(sfjc, rs);
|
||||
fetch_config_from_gitmodules(the_repository, sfjc, rs);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -463,16 +463,6 @@ static int grep_submodule(struct grep_opt *opt,
|
|||
ALLOC_GROW(repos_to_free, repos_to_free_nr + 1, repos_to_free_alloc);
|
||||
repos_to_free[repos_to_free_nr++] = subrepo;
|
||||
|
||||
/*
|
||||
* NEEDSWORK: repo_read_gitmodules() might call
|
||||
* odb_add_to_alternates_memory() via config_from_gitmodules(). This
|
||||
* operation causes a race condition with concurrent object readings
|
||||
* performed by the worker threads. That's why we need obj_read_lock()
|
||||
* here. It should be removed once it's no longer necessary to add the
|
||||
* subrepo's odbs to the in-memory alternates list.
|
||||
*/
|
||||
obj_read_lock();
|
||||
|
||||
/*
|
||||
* NEEDSWORK: when reading a submodule, the sparsity settings in the
|
||||
* superproject are incorrectly forgotten or misused. For example:
|
||||
|
|
@ -498,18 +488,14 @@ static int grep_submodule(struct grep_opt *opt,
|
|||
* ditto.
|
||||
*
|
||||
* Note that this list is not exhaustive.
|
||||
*
|
||||
* NEEDSWORK: initializing the subrepository is not thread-safe,
|
||||
* either, as it may cause us to race around `get_main_ref_store()`. We
|
||||
* thus need to hold the object-read lock to serialize all readers with
|
||||
* one another.
|
||||
*/
|
||||
obj_read_lock();
|
||||
repo_read_gitmodules(subrepo, 0);
|
||||
|
||||
/*
|
||||
* All code paths tested by test code no longer need submodule ODBs to
|
||||
* be added as alternates, but add it to the list just in case.
|
||||
* Submodule ODBs added through add_submodule_odb_by_path() will be
|
||||
* lazily registered as alternates when needed (and except in an
|
||||
* unexpected code interaction, it won't be needed).
|
||||
*/
|
||||
odb_add_submodule_source_by_path(the_repository->objects,
|
||||
subrepo->objects->sources->path);
|
||||
obj_read_unlock();
|
||||
|
||||
memcpy(&subopt, opt, sizeof(subopt));
|
||||
|
|
@ -897,7 +883,7 @@ static int grep_objects(struct grep_opt *opt, const struct pathspec *pathspec,
|
|||
if (recurse_submodules) {
|
||||
submodule_free(opt->repo);
|
||||
obj_read_lock();
|
||||
gitmodules_config_oid(&real_obj->oid);
|
||||
gitmodules_config_oid(the_repository, &real_obj->oid);
|
||||
obj_read_unlock();
|
||||
}
|
||||
if (grep_object(opt, pathspec, real_obj, list->objects[i].name,
|
||||
|
|
|
|||
|
|
@ -90,7 +90,8 @@ static struct odb_source_files *handle_object_dir_option(struct repository *repo
|
|||
{
|
||||
struct odb_source *source = odb_find_source(repo->objects, opts.object_dir);
|
||||
if (!source)
|
||||
source = odb_add_to_alternates_memory(repo->objects, opts.object_dir);
|
||||
die(_("object directory is not an alternate of the current repository: '%s'"),
|
||||
opts.object_dir);
|
||||
return odb_source_files_downcast(source);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3041,7 +3041,7 @@ static int module_update(int argc, const char **argv, const char *prefix,
|
|||
NULL
|
||||
};
|
||||
|
||||
update_clone_config_from_gitmodules(&opt.max_jobs);
|
||||
update_clone_config_from_gitmodules(the_repository, &opt.max_jobs);
|
||||
repo_config(the_repository, git_update_clone_config, &opt.max_jobs);
|
||||
|
||||
argc = parse_options(argc, argv, prefix, module_update_options,
|
||||
|
|
@ -3255,7 +3255,7 @@ static int module_set_url(int argc, const char **argv, const char *prefix,
|
|||
path);
|
||||
|
||||
config_name = xstrfmt("submodule.%s.url", sub->name);
|
||||
ret = config_set_in_gitmodules_file_gently(config_name, newurl);
|
||||
ret = config_set_in_gitmodules_file_gently(the_repository, config_name, newurl);
|
||||
|
||||
if (!ret) {
|
||||
repo_read_gitmodules(the_repository, 0);
|
||||
|
|
@ -3311,7 +3311,7 @@ static int module_set_branch(int argc, const char **argv, const char *prefix,
|
|||
path);
|
||||
|
||||
config_name = xstrfmt("submodule.%s.branch", sub->name);
|
||||
ret = config_set_in_gitmodules_file_gently(config_name, opt_branch);
|
||||
ret = config_set_in_gitmodules_file_gently(the_repository, config_name, opt_branch);
|
||||
|
||||
free(config_name);
|
||||
return !!ret;
|
||||
|
|
@ -3511,7 +3511,7 @@ static int config_submodule_in_gitmodules(const char *name, const char *var, con
|
|||
die(_("please make sure that the .gitmodules file is in the working tree"));
|
||||
|
||||
key = xstrfmt("submodule.%s.%s", name, var);
|
||||
ret = config_set_in_gitmodules_file_gently(key, value);
|
||||
ret = config_set_in_gitmodules_file_gently(the_repository, key, value);
|
||||
free(key);
|
||||
|
||||
return ret;
|
||||
|
|
|
|||
88
cache-tree.c
88
cache-tree.c
|
|
@ -1,4 +1,3 @@
|
|||
#define USE_THE_REPOSITORY_VARIABLE
|
||||
#define DISABLE_SIGN_COMPARE_WARNINGS
|
||||
|
||||
#include "git-compat-util.h"
|
||||
|
|
@ -275,28 +274,30 @@ static void discard_unused_subtrees(struct cache_tree *it)
|
|||
}
|
||||
}
|
||||
|
||||
int cache_tree_fully_valid(struct cache_tree *it)
|
||||
int cache_tree_fully_valid(struct repository *repo, struct cache_tree *it)
|
||||
{
|
||||
int i;
|
||||
if (!it)
|
||||
return 0;
|
||||
if (it->entry_count < 0 ||
|
||||
!odb_has_object(the_repository->objects, &it->oid,
|
||||
!odb_has_object(repo->objects, &it->oid,
|
||||
ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))
|
||||
return 0;
|
||||
for (i = 0; i < it->subtree_nr; i++) {
|
||||
if (!cache_tree_fully_valid(it->down[i]->cache_tree))
|
||||
if (!cache_tree_fully_valid(repo, it->down[i]->cache_tree))
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int must_check_existence(const struct cache_entry *ce)
|
||||
static int must_check_existence(const struct cache_entry *ce, void *cb_data)
|
||||
{
|
||||
return !(repo_has_promisor_remote(the_repository) && ce_skip_worktree(ce));
|
||||
struct repository *repo = cb_data;
|
||||
return !(repo_has_promisor_remote(repo) && ce_skip_worktree(ce));
|
||||
}
|
||||
|
||||
static int update_one(struct cache_tree *it,
|
||||
static int update_one(struct repository *repo,
|
||||
struct cache_tree *it,
|
||||
struct cache_entry **cache,
|
||||
int entries,
|
||||
const char *base,
|
||||
|
|
@ -334,7 +335,7 @@ static int update_one(struct cache_tree *it,
|
|||
}
|
||||
|
||||
if (0 <= it->entry_count &&
|
||||
odb_has_object(the_repository->objects, &it->oid,
|
||||
odb_has_object(repo->objects, &it->oid,
|
||||
ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))
|
||||
return it->entry_count;
|
||||
|
||||
|
|
@ -375,7 +376,8 @@ static int update_one(struct cache_tree *it,
|
|||
sub = find_subtree(it, path + baselen, sublen, 1);
|
||||
if (!sub->cache_tree)
|
||||
sub->cache_tree = cache_tree();
|
||||
subcnt = update_one(sub->cache_tree,
|
||||
subcnt = update_one(repo,
|
||||
sub->cache_tree,
|
||||
cache + i, entries - i,
|
||||
path,
|
||||
baselen + sublen + 1,
|
||||
|
|
@ -439,10 +441,10 @@ static int update_one(struct cache_tree *it,
|
|||
}
|
||||
|
||||
ce_missing_ok = mode == S_IFGITLINK || missing_ok ||
|
||||
!must_check_existence(ce);
|
||||
!must_check_existence(ce, repo);
|
||||
if (is_null_oid(oid) ||
|
||||
(!ce_missing_ok &&
|
||||
!odb_has_object(the_repository->objects, oid,
|
||||
!odb_has_object(repo->objects, oid,
|
||||
ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))) {
|
||||
strbuf_release(&buffer);
|
||||
if (expected_missing)
|
||||
|
|
@ -474,12 +476,12 @@ static int update_one(struct cache_tree *it,
|
|||
/*
|
||||
* "sub" can be an empty tree if all subentries are i-t-a.
|
||||
*/
|
||||
if (contains_ita && is_empty_tree_oid(oid, the_repository->hash_algo))
|
||||
if (contains_ita && is_empty_tree_oid(oid, repo->hash_algo))
|
||||
continue;
|
||||
|
||||
strbuf_grow(&buffer, entlen + 100);
|
||||
strbuf_addf(&buffer, "%o %.*s%c", mode, entlen, path + baselen, '\0');
|
||||
strbuf_add(&buffer, oid->hash, the_hash_algo->rawsz);
|
||||
strbuf_add(&buffer, oid->hash, repo->hash_algo->rawsz);
|
||||
|
||||
#if DEBUG_CACHE_TREE
|
||||
fprintf(stderr, "cache-tree update-one %o %.*s\n",
|
||||
|
|
@ -489,16 +491,16 @@ static int update_one(struct cache_tree *it,
|
|||
|
||||
if (repair) {
|
||||
struct object_id oid;
|
||||
hash_object_file(the_hash_algo, buffer.buf, buffer.len,
|
||||
hash_object_file(repo->hash_algo, buffer.buf, buffer.len,
|
||||
OBJ_TREE, &oid);
|
||||
if (odb_has_object(the_repository->objects, &oid, ODB_HAS_OBJECT_RECHECK_PACKED))
|
||||
if (odb_has_object(repo->objects, &oid, ODB_HAS_OBJECT_RECHECK_PACKED))
|
||||
oidcpy(&it->oid, &oid);
|
||||
else
|
||||
to_invalidate = 1;
|
||||
} else if (dryrun) {
|
||||
hash_object_file(the_hash_algo, buffer.buf, buffer.len,
|
||||
hash_object_file(repo->hash_algo, buffer.buf, buffer.len,
|
||||
OBJ_TREE, &it->oid);
|
||||
} else if (odb_write_object_ext(the_repository->objects, buffer.buf, buffer.len, OBJ_TREE,
|
||||
} else if (odb_write_object_ext(repo->objects, buffer.buf, buffer.len, OBJ_TREE,
|
||||
&it->oid, NULL, flags & WRITE_TREE_SILENT ? ODB_WRITE_OBJECT_SILENT : 0)) {
|
||||
strbuf_release(&buffer);
|
||||
return -1;
|
||||
|
|
@ -516,7 +518,7 @@ static int update_one(struct cache_tree *it,
|
|||
|
||||
int cache_tree_update(struct index_state *istate, int flags)
|
||||
{
|
||||
int inflight = !!the_repository->objects->transaction;
|
||||
int inflight = !!istate->repo->objects->transaction;
|
||||
struct odb_transaction *transaction;
|
||||
int skip, i;
|
||||
|
||||
|
|
@ -528,14 +530,14 @@ int cache_tree_update(struct index_state *istate, int flags)
|
|||
if (!istate->cache_tree)
|
||||
istate->cache_tree = cache_tree();
|
||||
|
||||
if (!(flags & WRITE_TREE_MISSING_OK) && repo_has_promisor_remote(the_repository))
|
||||
prefetch_cache_entries(istate, must_check_existence);
|
||||
if (!(flags & WRITE_TREE_MISSING_OK) && repo_has_promisor_remote(istate->repo))
|
||||
prefetch_cache_entries(istate, must_check_existence, istate->repo);
|
||||
|
||||
trace_performance_enter();
|
||||
trace2_region_enter("cache_tree", "update", istate->repo);
|
||||
if (!inflight)
|
||||
odb_transaction_begin_or_die(the_repository->objects, &transaction, 0);
|
||||
i = update_one(istate->cache_tree, istate->cache, istate->cache_nr,
|
||||
odb_transaction_begin_or_die(istate->repo->objects, &transaction, 0);
|
||||
i = update_one(istate->repo, istate->cache_tree, istate->cache, istate->cache_nr,
|
||||
"", 0, &skip, flags);
|
||||
if (!inflight)
|
||||
odb_transaction_commit_and_finalize_or_die(transaction);
|
||||
|
|
@ -547,7 +549,8 @@ int cache_tree_update(struct index_state *istate, int flags)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void write_one(struct strbuf *buffer, struct cache_tree *it,
|
||||
static void write_one(struct repository *repo,
|
||||
struct strbuf *buffer, struct cache_tree *it,
|
||||
const char *path, int pathlen)
|
||||
{
|
||||
int i;
|
||||
|
|
@ -573,7 +576,7 @@ static void write_one(struct strbuf *buffer, struct cache_tree *it,
|
|||
#endif
|
||||
|
||||
if (0 <= it->entry_count) {
|
||||
strbuf_add(buffer, it->oid.hash, the_hash_algo->rawsz);
|
||||
strbuf_add(buffer, it->oid.hash, repo->hash_algo->rawsz);
|
||||
}
|
||||
for (i = 0; i < it->subtree_nr; i++) {
|
||||
struct cache_tree_sub *down = it->down[i];
|
||||
|
|
@ -583,15 +586,16 @@ static void write_one(struct strbuf *buffer, struct cache_tree *it,
|
|||
prev->name, prev->namelen) <= 0)
|
||||
die("fatal - unsorted cache subtree");
|
||||
}
|
||||
write_one(buffer, down->cache_tree, down->name, down->namelen);
|
||||
write_one(repo, buffer, down->cache_tree, down->name, down->namelen);
|
||||
}
|
||||
}
|
||||
|
||||
void cache_tree_write(struct strbuf *sb, struct cache_tree *root)
|
||||
void cache_tree_write(struct repository *repo,
|
||||
struct strbuf *sb, struct cache_tree *root)
|
||||
{
|
||||
trace2_region_enter("cache_tree", "write", the_repository);
|
||||
write_one(sb, root, "", 0);
|
||||
trace2_region_leave("cache_tree", "write", the_repository);
|
||||
trace2_region_enter("cache_tree", "write", repo);
|
||||
write_one(repo, sb, root, "", 0);
|
||||
trace2_region_leave("cache_tree", "write", repo);
|
||||
}
|
||||
|
||||
static int parse_int(const char **ptr, unsigned long *len_p, int *out)
|
||||
|
|
@ -625,13 +629,14 @@ static int parse_int(const char **ptr, unsigned long *len_p, int *out)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static struct cache_tree *read_one(const char **buffer, unsigned long *size_p)
|
||||
static struct cache_tree *read_one(struct repository *repo,
|
||||
const char **buffer, unsigned long *size_p)
|
||||
{
|
||||
const char *buf = *buffer;
|
||||
unsigned long size = *size_p;
|
||||
struct cache_tree *it;
|
||||
int i, subtree_nr;
|
||||
const unsigned rawsz = the_hash_algo->rawsz;
|
||||
const unsigned rawsz = repo->hash_algo->rawsz;
|
||||
|
||||
it = NULL;
|
||||
/* skip name, but make sure name exists */
|
||||
|
|
@ -658,7 +663,7 @@ static struct cache_tree *read_one(const char **buffer, unsigned long *size_p)
|
|||
if (size < rawsz)
|
||||
goto free_return;
|
||||
oidread(&it->oid, (const unsigned char *)buf,
|
||||
the_repository->hash_algo);
|
||||
repo->hash_algo);
|
||||
buf += rawsz;
|
||||
size -= rawsz;
|
||||
}
|
||||
|
|
@ -686,7 +691,7 @@ static struct cache_tree *read_one(const char **buffer, unsigned long *size_p)
|
|||
struct cache_tree_sub *subtree;
|
||||
const char *name = buf;
|
||||
|
||||
sub = read_one(&buf, &size);
|
||||
sub = read_one(repo, &buf, &size);
|
||||
if (!sub)
|
||||
goto free_return;
|
||||
subtree = cache_tree_sub(it, name);
|
||||
|
|
@ -703,16 +708,17 @@ static struct cache_tree *read_one(const char **buffer, unsigned long *size_p)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
struct cache_tree *cache_tree_read(const char *buffer, unsigned long size)
|
||||
struct cache_tree *cache_tree_read(struct repository *repo,
|
||||
const char *buffer, unsigned long size)
|
||||
{
|
||||
struct cache_tree *result;
|
||||
|
||||
if (buffer[0])
|
||||
return NULL; /* not the whole tree */
|
||||
|
||||
trace2_region_enter("cache_tree", "read", the_repository);
|
||||
result = read_one(&buffer, &size);
|
||||
trace2_region_leave("cache_tree", "read", the_repository);
|
||||
trace2_region_enter("cache_tree", "read", repo);
|
||||
result = read_one(repo, &buffer, &size);
|
||||
trace2_region_leave("cache_tree", "read", repo);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
@ -775,7 +781,7 @@ struct tree *write_in_core_index_as_tree(struct repository *repo,
|
|||
int was_valid, ret;
|
||||
|
||||
was_valid = index_state->cache_tree &&
|
||||
cache_tree_fully_valid(index_state->cache_tree);
|
||||
cache_tree_fully_valid(repo, index_state->cache_tree);
|
||||
|
||||
ret = write_index_as_tree_internal(&o, index_state, was_valid, 0, NULL);
|
||||
if (ret == WRITE_TREE_UNMERGED_INDEX) {
|
||||
|
|
@ -803,7 +809,7 @@ int write_index_as_tree(struct object_id *oid, struct index_state *index_state,
|
|||
hold_lock_file_for_update(&lock_file, index_path, LOCK_DIE_ON_ERROR);
|
||||
|
||||
entries = read_index_from(index_state, index_path,
|
||||
repo_get_git_dir(the_repository));
|
||||
repo_get_git_dir(index_state->repo));
|
||||
if (entries < 0) {
|
||||
ret = WRITE_TREE_UNREADABLE_INDEX;
|
||||
goto out;
|
||||
|
|
@ -811,7 +817,7 @@ int write_index_as_tree(struct object_id *oid, struct index_state *index_state,
|
|||
|
||||
was_valid = !(flags & WRITE_TREE_IGNORE_CACHE_TREE) &&
|
||||
index_state->cache_tree &&
|
||||
cache_tree_fully_valid(index_state->cache_tree);
|
||||
cache_tree_fully_valid(index_state->repo, index_state->cache_tree);
|
||||
|
||||
ret = write_index_as_tree_internal(oid, index_state, was_valid, flags,
|
||||
prefix);
|
||||
|
|
@ -859,7 +865,7 @@ static void prime_cache_tree_rec(struct repository *r,
|
|||
struct cache_tree_sub *sub;
|
||||
struct tree *subtree = lookup_tree(r, &entry.oid);
|
||||
|
||||
if (repo_parse_tree(the_repository, subtree) < 0)
|
||||
if (repo_parse_tree(r, subtree) < 0)
|
||||
exit(128);
|
||||
sub = cache_tree_sub(it, entry.path);
|
||||
sub->cache_tree = cache_tree();
|
||||
|
|
|
|||
|
|
@ -28,10 +28,11 @@ struct cache_tree_sub *cache_tree_sub(struct cache_tree *, const char *);
|
|||
|
||||
int cache_tree_subtree_pos(struct cache_tree *it, const char *path, int pathlen);
|
||||
|
||||
void cache_tree_write(struct strbuf *, struct cache_tree *root);
|
||||
struct cache_tree *cache_tree_read(const char *buffer, unsigned long size);
|
||||
void cache_tree_write(struct repository *repo, struct strbuf *, struct cache_tree *root);
|
||||
struct cache_tree *cache_tree_read(struct repository *repo,
|
||||
const char *buffer, unsigned long size);
|
||||
|
||||
int cache_tree_fully_valid(struct cache_tree *);
|
||||
int cache_tree_fully_valid(struct repository *, struct cache_tree *);
|
||||
int cache_tree_update(struct index_state *, int);
|
||||
int cache_tree_verify(struct repository *, struct index_state *);
|
||||
|
||||
|
|
|
|||
42
odb.c
42
odb.c
|
|
@ -238,12 +238,6 @@ static struct odb_source *odb_add_alternate_recursively(struct object_database *
|
|||
return alternate;
|
||||
}
|
||||
|
||||
struct odb_source *odb_add_to_alternates_memory(struct object_database *odb,
|
||||
const char *dir)
|
||||
{
|
||||
return odb_add_alternate_recursively(odb, dir, 0);
|
||||
}
|
||||
|
||||
struct odb_source *odb_set_temporary_primary_source(struct object_database *odb,
|
||||
const char *dir, int will_destroy,
|
||||
struct odb_source **prev_source)
|
||||
|
|
@ -379,12 +373,6 @@ struct odb_source *odb_find_source_or_die(struct object_database *odb, const cha
|
|||
return source;
|
||||
}
|
||||
|
||||
void odb_add_submodule_source_by_path(struct object_database *odb,
|
||||
const char *path)
|
||||
{
|
||||
string_list_insert(&odb->submodule_source_paths, path);
|
||||
}
|
||||
|
||||
static void fill_alternate_refs_command(struct repository *repo,
|
||||
struct child_process *cmd,
|
||||
const char *repo_path)
|
||||
|
|
@ -540,23 +528,6 @@ void disable_obj_read_lock(void)
|
|||
pthread_mutex_destroy(&obj_read_mutex);
|
||||
}
|
||||
|
||||
static int register_all_submodule_sources(struct object_database *odb)
|
||||
{
|
||||
int ret = odb->submodule_source_paths.nr;
|
||||
|
||||
for (size_t i = 0; i < odb->submodule_source_paths.nr; i++)
|
||||
odb_add_to_alternates_memory(odb,
|
||||
odb->submodule_source_paths.items[i].string);
|
||||
if (ret) {
|
||||
string_list_clear(&odb->submodule_source_paths, 0);
|
||||
trace2_data_intmax("submodule", odb->repo,
|
||||
"register_all_submodule_sources/registered", ret);
|
||||
if (git_env_bool("GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB", 0))
|
||||
BUG("register_all_submodule_sources() called");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static enum odb_read_status do_oid_object_info_extended(struct object_database *odb,
|
||||
const struct object_id *oid,
|
||||
struct object_info *oi, unsigned flags)
|
||||
|
|
@ -605,16 +576,6 @@ static enum odb_read_status do_oid_object_info_extended(struct object_database *
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This might be an attempt at accessing a submodule object as
|
||||
* if it were in main object store (having called
|
||||
* `odb_add_submodule_source_by_path()` on that submodule's
|
||||
* ODB). If any such ODBs exist, register them and try again.
|
||||
*/
|
||||
if (register_all_submodule_sources(odb))
|
||||
/* We added some alternates; retry */
|
||||
continue;
|
||||
|
||||
/* Check if it is a missing object */
|
||||
if (odb->repo->fetch_if_missing && repo_has_promisor_remote(odb->repo) &&
|
||||
!already_retried &&
|
||||
|
|
@ -1100,7 +1061,6 @@ struct object_database *odb_new(struct repository *repo,
|
|||
CALLOC_ARRAY(o, 1);
|
||||
o->repo = repo;
|
||||
pthread_mutex_init(&o->replace_mutex, NULL);
|
||||
string_list_init_dup(&o->submodule_source_paths);
|
||||
hashmap_init(&o->source_by_path, odb_source_by_path_cmp, o, 0);
|
||||
o->source_paths_icase = -1;
|
||||
|
||||
|
|
@ -1157,8 +1117,6 @@ void odb_free(struct object_database *o)
|
|||
odb_close(o);
|
||||
odb_free_sources(o);
|
||||
|
||||
string_list_clear(&o->submodule_source_paths, 0);
|
||||
|
||||
free(o);
|
||||
}
|
||||
|
||||
|
|
|
|||
22
odb.h
22
odb.h
|
|
@ -89,12 +89,6 @@ struct object_database {
|
|||
unsigned long object_count;
|
||||
unsigned object_count_flags;
|
||||
unsigned object_count_valid : 1;
|
||||
|
||||
/*
|
||||
* Submodule source paths that will be added as additional sources to
|
||||
* allow lookup of submodule objects via the main object database.
|
||||
*/
|
||||
struct string_list submodule_source_paths;
|
||||
};
|
||||
|
||||
enum odb_new_flags {
|
||||
|
|
@ -257,14 +251,6 @@ void odb_restore_primary_source(struct object_database *odb,
|
|||
struct odb_source *restore_source,
|
||||
const char *old_path);
|
||||
|
||||
/*
|
||||
* Call odb_add_submodule_source_by_path() to add the submodule at the given
|
||||
* path to a list. The object stores of all submodules in that list will be
|
||||
* added as additional sources in the object store when looking up objects.
|
||||
*/
|
||||
void odb_add_submodule_source_by_path(struct object_database *odb,
|
||||
const char *path);
|
||||
|
||||
/*
|
||||
* Iterate through all alternates of the database and execute the provided
|
||||
* callback function for each of them. Stop iterating once the callback
|
||||
|
|
@ -298,14 +284,6 @@ int odb_mkstemp(struct object_database *odb,
|
|||
*/
|
||||
int odb_has_alternates(struct object_database *odb);
|
||||
|
||||
/*
|
||||
* Add the directory to the in-memory list of alternate sources (along with any
|
||||
* recursive alternates it points to), but do not modify the on-disk alternates
|
||||
* file.
|
||||
*/
|
||||
struct odb_source *odb_add_to_alternates_memory(struct object_database *odb,
|
||||
const char *dir);
|
||||
|
||||
/*
|
||||
* Read an object from the database. Returns the object data and assigns object
|
||||
* type and size to the `type` and `size` pointers, if these pointers are
|
||||
|
|
|
|||
|
|
@ -845,6 +845,7 @@ static void odb_source_packed_free(struct odb_source *source)
|
|||
|
||||
chdir_notify_unregister(odb_source_packed_reparent, packed);
|
||||
|
||||
odb_source_close(source);
|
||||
for (struct packfile_list_entry *e = packed->packs.head; e; e = e->next)
|
||||
free(e->pack);
|
||||
packfile_list_clear(&packed->packs);
|
||||
|
|
|
|||
|
|
@ -269,9 +269,10 @@ void validate_cache_entries(const struct index_state *istate);
|
|||
* the given predicate. This function should only be called if
|
||||
* repo_has_promisor_remote() returns true.
|
||||
*/
|
||||
typedef int (*must_prefetch_predicate)(const struct cache_entry *);
|
||||
typedef int (*must_prefetch_predicate)(const struct cache_entry *, void *cb_data);
|
||||
void prefetch_cache_entries(const struct index_state *istate,
|
||||
must_prefetch_predicate must_prefetch);
|
||||
must_prefetch_predicate must_prefetch,
|
||||
void *cb_data);
|
||||
|
||||
/* Initialize and use the cache information */
|
||||
struct lock_file;
|
||||
|
|
|
|||
|
|
@ -1748,7 +1748,7 @@ static int read_index_extension(struct index_state *istate,
|
|||
{
|
||||
switch (CACHE_EXT(ext)) {
|
||||
case CACHE_EXT_TREE:
|
||||
istate->cache_tree = cache_tree_read(data, sz);
|
||||
istate->cache_tree = cache_tree_read(istate->repo, data, sz);
|
||||
break;
|
||||
case CACHE_EXT_RESOLVE_UNDO:
|
||||
istate->resolve_undo = resolve_undo_read(data, sz, the_hash_algo);
|
||||
|
|
@ -3012,7 +3012,7 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
|
|||
!drop_cache_tree && istate->cache_tree) {
|
||||
strbuf_reset(&sb);
|
||||
|
||||
cache_tree_write(&sb, istate->cache_tree);
|
||||
cache_tree_write(istate->repo, &sb, istate->cache_tree);
|
||||
err = write_index_ext_header(f, eoie_c, CACHE_EXT_TREE, sb.len) < 0;
|
||||
hashwrite(f, sb.buf, sb.len);
|
||||
if (err) {
|
||||
|
|
@ -3733,7 +3733,8 @@ static void write_ieot_extension(struct strbuf *sb, struct index_entry_offset_ta
|
|||
}
|
||||
|
||||
void prefetch_cache_entries(const struct index_state *istate,
|
||||
must_prefetch_predicate must_prefetch)
|
||||
must_prefetch_predicate must_prefetch,
|
||||
void *cb_data)
|
||||
{
|
||||
int i;
|
||||
struct oid_array to_fetch = OID_ARRAY_INIT;
|
||||
|
|
@ -3741,7 +3742,7 @@ void prefetch_cache_entries(const struct index_state *istate,
|
|||
for (i = 0; i < istate->cache_nr; i++) {
|
||||
struct cache_entry *ce = istate->cache[i];
|
||||
|
||||
if (S_ISGITLINK(ce->ce_mode) || !must_prefetch(ce))
|
||||
if (S_ISGITLINK(ce->ce_mode) || !must_prefetch(ce, cb_data))
|
||||
continue;
|
||||
if (!odb_read_object_info_extended(the_repository->objects,
|
||||
&ce->oid, NULL,
|
||||
|
|
|
|||
|
|
@ -821,7 +821,7 @@ static int do_recursive_merge(struct repository *r,
|
|||
|
||||
static struct object_id *get_cache_tree_oid(struct index_state *istate)
|
||||
{
|
||||
if (!cache_tree_fully_valid(istate->cache_tree))
|
||||
if (!cache_tree_fully_valid(istate->repo, istate->cache_tree))
|
||||
if (cache_tree_update(istate, 0)) {
|
||||
error(_("unable to update cache tree"));
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -228,7 +228,7 @@ int convert_to_sparse(struct index_state *istate, int flags)
|
|||
if (index_has_unmerged_entries(istate))
|
||||
return 0;
|
||||
|
||||
if (!cache_tree_fully_valid(istate->cache_tree)) {
|
||||
if (!cache_tree_fully_valid(istate->repo, istate->cache_tree)) {
|
||||
/* Clear and recompute the cache-tree */
|
||||
cache_tree_free(&istate->cache_tree);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
#define USE_THE_REPOSITORY_VARIABLE
|
||||
#define DISABLE_SIGN_COMPARE_WARNINGS
|
||||
|
||||
#include "git-compat-util.h"
|
||||
|
|
@ -133,7 +132,9 @@ void submodule_cache_free(struct submodule_cache *cache)
|
|||
static unsigned int hash_oid_string(const struct object_id *oid,
|
||||
const char *string)
|
||||
{
|
||||
return memhash(oid->hash, the_hash_algo->rawsz) + strhash(string);
|
||||
if (oid->algo == GIT_HASH_UNKNOWN)
|
||||
BUG("hashing an object ID with unknown algorithm");
|
||||
return memhash(oid->hash, hash_algos[oid->algo].rawsz) + strhash(string);
|
||||
}
|
||||
|
||||
static void cache_put_path(struct submodule_cache *cache,
|
||||
|
|
@ -667,19 +668,20 @@ static int parse_config(const char *var, const char *value,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int gitmodule_oid_from_commit(const struct object_id *treeish_name,
|
||||
static int gitmodule_oid_from_commit(struct repository *repo,
|
||||
const struct object_id *treeish_name,
|
||||
struct object_id *gitmodules_oid,
|
||||
struct strbuf *rev)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (is_null_oid(treeish_name)) {
|
||||
oidclr(gitmodules_oid, the_repository->hash_algo);
|
||||
oidclr(gitmodules_oid, repo->hash_algo);
|
||||
return 1;
|
||||
}
|
||||
|
||||
strbuf_addf(rev, "%s:.gitmodules", oid_to_hex(treeish_name));
|
||||
if (repo_get_oid(the_repository, rev->buf, gitmodules_oid) >= 0)
|
||||
if (repo_get_oid(repo, rev->buf, gitmodules_oid) >= 0)
|
||||
ret = 1;
|
||||
|
||||
return ret;
|
||||
|
|
@ -689,9 +691,11 @@ static int gitmodule_oid_from_commit(const struct object_id *treeish_name,
|
|||
* (key) with on-demand reading of the appropriate .gitmodules from
|
||||
* revisions.
|
||||
*/
|
||||
static const struct submodule *config_from(struct submodule_cache *cache,
|
||||
const struct object_id *treeish_name, const char *key,
|
||||
enum lookup_type lookup_type)
|
||||
static const struct submodule *config_from(struct repository *repo,
|
||||
struct submodule_cache *cache,
|
||||
const struct object_id *treeish_name,
|
||||
const char *key,
|
||||
enum lookup_type lookup_type)
|
||||
{
|
||||
struct strbuf rev = STRBUF_INIT;
|
||||
size_t config_size;
|
||||
|
|
@ -718,7 +722,7 @@ static const struct submodule *config_from(struct submodule_cache *cache,
|
|||
return entry->config;
|
||||
}
|
||||
|
||||
if (!gitmodule_oid_from_commit(treeish_name, &oid, &rev))
|
||||
if (!gitmodule_oid_from_commit(repo, treeish_name, &oid, &rev))
|
||||
goto out;
|
||||
|
||||
switch (lookup_type) {
|
||||
|
|
@ -732,7 +736,7 @@ static const struct submodule *config_from(struct submodule_cache *cache,
|
|||
if (submodule)
|
||||
goto out;
|
||||
|
||||
config = odb_read_object(the_repository->objects, &oid,
|
||||
config = odb_read_object(repo->objects, &oid,
|
||||
&type, &config_size);
|
||||
if (!config || type != OBJ_BLOB)
|
||||
goto out;
|
||||
|
|
@ -798,9 +802,6 @@ static void config_from_gitmodules(config_fn_t fn, struct repository *repo, void
|
|||
} else if (repo_get_oid(repo, GITMODULES_INDEX, &oid) >= 0 ||
|
||||
repo_get_oid(repo, GITMODULES_HEAD, &oid) >= 0) {
|
||||
config_source.blob = oidstr = xstrdup(oid_to_hex(&oid));
|
||||
if (repo != the_repository)
|
||||
odb_add_submodule_source_by_path(the_repository->objects,
|
||||
repo->objects->sources->path);
|
||||
} else {
|
||||
goto out;
|
||||
}
|
||||
|
|
@ -821,7 +822,7 @@ static int gitmodules_cb(const char *var, const char *value,
|
|||
|
||||
parameter.cache = repo->submodule_cache;
|
||||
parameter.treeish_name = NULL;
|
||||
parameter.gitmodules_oid = null_oid(the_hash_algo);
|
||||
parameter.gitmodules_oid = null_oid(repo->hash_algo);
|
||||
parameter.overwrite = 1;
|
||||
|
||||
return parse_config(var, value, ctx, ¶meter);
|
||||
|
|
@ -843,21 +844,22 @@ void repo_read_gitmodules(struct repository *repo, int skip_if_read)
|
|||
repo->submodule_cache->gitmodules_read = 1;
|
||||
}
|
||||
|
||||
void gitmodules_config_oid(const struct object_id *commit_oid)
|
||||
void gitmodules_config_oid(struct repository *repo,
|
||||
const struct object_id *commit_oid)
|
||||
{
|
||||
struct strbuf rev = STRBUF_INIT;
|
||||
struct object_id oid;
|
||||
|
||||
submodule_cache_check_init(the_repository);
|
||||
submodule_cache_check_init(repo);
|
||||
|
||||
if (gitmodule_oid_from_commit(commit_oid, &oid, &rev)) {
|
||||
if (gitmodule_oid_from_commit(repo, commit_oid, &oid, &rev)) {
|
||||
git_config_from_blob_oid(gitmodules_cb, rev.buf,
|
||||
the_repository, &oid, the_repository,
|
||||
repo, &oid, repo,
|
||||
CONFIG_SCOPE_UNKNOWN);
|
||||
}
|
||||
strbuf_release(&rev);
|
||||
|
||||
the_repository->submodule_cache->gitmodules_read = 1;
|
||||
repo->submodule_cache->gitmodules_read = 1;
|
||||
}
|
||||
|
||||
const struct submodule *submodule_from_name(struct repository *r,
|
||||
|
|
@ -865,7 +867,7 @@ const struct submodule *submodule_from_name(struct repository *r,
|
|||
const char *name)
|
||||
{
|
||||
repo_read_gitmodules(r, 1);
|
||||
return config_from(r->submodule_cache, treeish_name, name, lookup_name);
|
||||
return config_from(r, r->submodule_cache, treeish_name, name, lookup_name);
|
||||
}
|
||||
|
||||
const struct submodule *submodule_from_path(struct repository *r,
|
||||
|
|
@ -873,7 +875,7 @@ const struct submodule *submodule_from_path(struct repository *r,
|
|||
const char *path)
|
||||
{
|
||||
repo_read_gitmodules(r, 1);
|
||||
return config_from(r->submodule_cache, treeish_name, path, lookup_path);
|
||||
return config_from(r, r->submodule_cache, treeish_name, path, lookup_path);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -980,11 +982,12 @@ int print_config_from_gitmodules(struct repository *repo, const char *key)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int config_set_in_gitmodules_file_gently(const char *key, const char *value)
|
||||
int config_set_in_gitmodules_file_gently(struct repository *repo,
|
||||
const char *key, const char *value)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = repo_config_set_in_file_gently(the_repository, GITMODULES_FILE, key, NULL, value);
|
||||
ret = repo_config_set_in_file_gently(repo, GITMODULES_FILE, key, NULL, value);
|
||||
if (ret < 0)
|
||||
/* Maybe the user already did that, don't error out here */
|
||||
warning(_("Could not update .gitmodules entry %s"), key);
|
||||
|
|
@ -1017,13 +1020,15 @@ static int gitmodules_fetch_config(const char *var, const char *value,
|
|||
return 0;
|
||||
}
|
||||
|
||||
void fetch_config_from_gitmodules(int *max_children, int *recurse_submodules)
|
||||
void fetch_config_from_gitmodules(struct repository *repo,
|
||||
int *max_children,
|
||||
int *recurse_submodules)
|
||||
{
|
||||
struct fetch_config config = {
|
||||
.max_children = max_children,
|
||||
.recurse_submodules = recurse_submodules
|
||||
};
|
||||
config_from_gitmodules(gitmodules_fetch_config, the_repository, &config);
|
||||
config_from_gitmodules(gitmodules_fetch_config, repo, &config);
|
||||
}
|
||||
|
||||
static int gitmodules_update_clone_config(const char *var, const char *value,
|
||||
|
|
@ -1036,7 +1041,7 @@ static int gitmodules_update_clone_config(const char *var, const char *value,
|
|||
return 0;
|
||||
}
|
||||
|
||||
void update_clone_config_from_gitmodules(int *max_jobs)
|
||||
void update_clone_config_from_gitmodules(struct repository *repo, int *max_jobs)
|
||||
{
|
||||
config_from_gitmodules(gitmodules_update_clone_config, the_repository, max_jobs);
|
||||
config_from_gitmodules(gitmodules_update_clone_config, repo, max_jobs);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,8 @@ int option_fetch_parse_recurse_submodules(const struct option *opt,
|
|||
int parse_update_recurse_submodules_arg(const char *opt, const char *arg);
|
||||
int parse_push_recurse_submodules_arg(const char *opt, const char *arg);
|
||||
void repo_read_gitmodules(struct repository *repo, int skip_if_read);
|
||||
void gitmodules_config_oid(const struct object_id *commit_oid);
|
||||
void gitmodules_config_oid(struct repository *repo,
|
||||
const struct object_id *commit_oid);
|
||||
|
||||
/**
|
||||
* Same as submodule_from_path but lookup by name.
|
||||
|
|
@ -80,7 +81,8 @@ const struct submodule *submodule_from_path(struct repository *r,
|
|||
void submodule_free(struct repository *r);
|
||||
|
||||
int print_config_from_gitmodules(struct repository *repo, const char *key);
|
||||
int config_set_in_gitmodules_file_gently(const char *key, const char *value);
|
||||
int config_set_in_gitmodules_file_gently(struct repository *repo,
|
||||
const char *key, const char *value);
|
||||
|
||||
/*
|
||||
* Returns 0 if the name is syntactically acceptable as a submodule "name"
|
||||
|
|
@ -100,8 +102,10 @@ int check_submodule_url(const char *url);
|
|||
* New helpers to retrieve arbitrary configuration from the '.gitmodules' file
|
||||
* should NOT be added.
|
||||
*/
|
||||
void fetch_config_from_gitmodules(int *max_children, int *recurse_submodules);
|
||||
void update_clone_config_from_gitmodules(int *max_jobs);
|
||||
void fetch_config_from_gitmodules(struct repository *repo,
|
||||
int *max_children,
|
||||
int *recurse_submodules);
|
||||
void update_clone_config_from_gitmodules(struct repository *repo, int *max_jobs);
|
||||
|
||||
/*
|
||||
* Submodule entry that contains relevant information about a
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ int update_path_in_gitmodules(const char *oldpath, const char *newpath)
|
|||
strbuf_addstr(&entry, "submodule.");
|
||||
strbuf_addstr(&entry, submodule->name);
|
||||
strbuf_addstr(&entry, ".path");
|
||||
ret = config_set_in_gitmodules_file_gently(entry.buf, newpath);
|
||||
ret = config_set_in_gitmodules_file_gently(the_repository, entry.buf, newpath);
|
||||
strbuf_release(&entry);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
7
t/README
7
t/README
|
|
@ -462,13 +462,6 @@ GIT_TEST_CHECKOUT_WORKERS=<n> overrides the 'checkout.workers' setting
|
|||
to <n> and 'checkout.thresholdForParallelism' to 0, forcing the
|
||||
execution of the parallel-checkout code.
|
||||
|
||||
GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=<boolean>, when true, makes
|
||||
registering submodule ODBs as alternates a fatal action. Support for
|
||||
this environment variable can be removed once the migration to
|
||||
explicitly providing repositories when accessing submodule objects is
|
||||
complete or needs to be abandoned for whatever reason (in which case the
|
||||
migrated codepaths still retain their performance benefits).
|
||||
|
||||
GIT_TEST_REQUIRE_PREREQ=<list> allows specifying a space separated list of
|
||||
prereqs that are required to succeed. If a prereq in this list is triggered by
|
||||
a test and then fails then the whole test run will abort. This can help to make
|
||||
|
|
|
|||
|
|
@ -5,34 +5,42 @@
|
|||
#include "midx.h"
|
||||
#include "repository.h"
|
||||
#include "odb.h"
|
||||
#include "odb/source-packed.h"
|
||||
#include "pack-bitmap.h"
|
||||
#include "packfile.h"
|
||||
#include "setup.h"
|
||||
#include "gettext.h"
|
||||
#include "pack-revindex.h"
|
||||
|
||||
static struct multi_pack_index *setup_midx(const char *object_dir)
|
||||
static struct multi_pack_index *setup_midx(const char *object_dir,
|
||||
struct odb_source_packed **out)
|
||||
{
|
||||
struct odb_source_files *files;
|
||||
struct odb_source_packed *packed;
|
||||
struct odb_source *source;
|
||||
setup_git_directory(the_repository);
|
||||
source = odb_find_source(the_repository->objects, object_dir);
|
||||
if (!source)
|
||||
source = odb_add_to_alternates_memory(the_repository->objects,
|
||||
object_dir);
|
||||
files = odb_source_files_downcast(source);
|
||||
|
||||
return load_multi_pack_index(files->packed);
|
||||
setup_git_directory(the_repository);
|
||||
|
||||
source = odb_find_source(the_repository->objects, object_dir);
|
||||
if (source) {
|
||||
packed = odb_source_files_downcast(source)->packed;
|
||||
} else {
|
||||
packed = odb_source_packed_new(the_repository->objects,
|
||||
object_dir, false);
|
||||
*out = packed;
|
||||
}
|
||||
|
||||
return load_multi_pack_index(packed);
|
||||
}
|
||||
|
||||
static int read_midx_file(const char *object_dir, const char *checksum,
|
||||
int show_objects)
|
||||
{
|
||||
struct odb_source_packed *packed = NULL;
|
||||
uint32_t i;
|
||||
struct multi_pack_index *m, *tip;
|
||||
int ret = 0;
|
||||
|
||||
m = tip = setup_midx(object_dir);
|
||||
m = tip = setup_midx(object_dir, &packed);
|
||||
|
||||
if (!m)
|
||||
return 1;
|
||||
|
|
@ -91,29 +99,35 @@ static int read_midx_file(const char *object_dir, const char *checksum,
|
|||
|
||||
out:
|
||||
close_midx(tip);
|
||||
if (packed)
|
||||
odb_source_free(&packed->base);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int read_midx_checksum(const char *object_dir)
|
||||
{
|
||||
struct odb_source_packed *packed = NULL;
|
||||
struct multi_pack_index *m;
|
||||
|
||||
m = setup_midx(object_dir);
|
||||
m = setup_midx(object_dir, &packed);
|
||||
if (!m)
|
||||
return 1;
|
||||
printf("%s\n", midx_get_checksum_hex(m));
|
||||
|
||||
close_midx(m);
|
||||
if (packed)
|
||||
odb_source_free(&packed->base);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int read_midx_preferred_pack(const char *object_dir)
|
||||
{
|
||||
struct odb_source_packed *packed = NULL;
|
||||
struct multi_pack_index *midx = NULL;
|
||||
uint32_t preferred_pack;
|
||||
|
||||
midx = setup_midx(object_dir);
|
||||
midx = setup_midx(object_dir, &packed);
|
||||
if (!midx)
|
||||
return 1;
|
||||
|
||||
|
|
@ -124,17 +138,21 @@ static int read_midx_preferred_pack(const char *object_dir)
|
|||
}
|
||||
|
||||
printf("%s\n", midx->pack_names[preferred_pack]);
|
||||
|
||||
close_midx(midx);
|
||||
if (packed)
|
||||
odb_source_free(&packed->base);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int read_midx_bitmapped_packs(const char *object_dir)
|
||||
{
|
||||
struct odb_source_packed *packed = NULL;
|
||||
struct multi_pack_index *midx = NULL;
|
||||
struct bitmapped_pack pack;
|
||||
uint32_t i;
|
||||
|
||||
midx = setup_midx(object_dir);
|
||||
midx = setup_midx(object_dir, &packed);
|
||||
if (!midx)
|
||||
return 1;
|
||||
|
||||
|
|
@ -150,7 +168,8 @@ static int read_midx_bitmapped_packs(const char *object_dir)
|
|||
}
|
||||
|
||||
close_midx(midx);
|
||||
|
||||
if (packed)
|
||||
odb_source_free(&packed->base);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -74,14 +74,6 @@ static const char **get_store(const char **argv, struct ref_store **refs)
|
|||
} else if (!strcmp(argv[0], "main")) {
|
||||
*refs = get_main_ref_store(the_repository);
|
||||
} else if (skip_prefix(argv[0], "submodule:", &gitdir)) {
|
||||
struct strbuf sb = STRBUF_INIT;
|
||||
|
||||
if (!repo_submodule_path_append(the_repository,
|
||||
&sb, gitdir, "objects/"))
|
||||
die("computing submodule path failed");
|
||||
odb_add_to_alternates_memory(the_repository->objects, sb.buf);
|
||||
strbuf_release(&sb);
|
||||
|
||||
*refs = repo_get_submodule_ref_store(the_repository, gitdir);
|
||||
} else if (skip_prefix(argv[0], "worktree:", &gitdir)) {
|
||||
struct worktree **p, **worktrees = get_worktrees(the_repository);
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ static int cmd__submodule_config_set(int argc, const char **argv)
|
|||
if (!is_writing_gitmodules_ok())
|
||||
die("please make sure that the .gitmodules file is in the working tree");
|
||||
|
||||
return config_set_in_gitmodules_file_gently(argv[1], argv[2]);
|
||||
return config_set_in_gitmodules_file_gently(the_repository, argv[1], argv[2]);
|
||||
}
|
||||
usage_with_options(usage, options);
|
||||
}
|
||||
|
|
@ -188,7 +188,7 @@ static int cmd__submodule_config_unset(int argc, const char **argv)
|
|||
if (argc == 2) {
|
||||
if (!is_writing_gitmodules_ok())
|
||||
die("please make sure that the .gitmodules file is in the working tree");
|
||||
return config_set_in_gitmodules_file_gently(argv[1], NULL);
|
||||
return config_set_in_gitmodules_file_gently(the_repository, argv[1], NULL);
|
||||
}
|
||||
usage_with_options(usage, options);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -711,10 +711,9 @@ test_expect_success 'force some 64-bit offsets with pack-objects' '
|
|||
corrupt_data $idx64 $(test_oid idxoff) "\02" &&
|
||||
# objects64 is not a real repository, but can serve as an alternate
|
||||
# anyway so we can write a MIDX into it
|
||||
git init repo &&
|
||||
test_when_finished "rm -fr repo" &&
|
||||
git init repo64 &&
|
||||
(
|
||||
cd repo &&
|
||||
cd repo64 &&
|
||||
( cd ../objects64 && pwd ) >.git/objects/info/alternates &&
|
||||
midx64=$(git multi-pack-index --object-dir=../objects64 write)
|
||||
) &&
|
||||
|
|
@ -722,7 +721,7 @@ test_expect_success 'force some 64-bit offsets with pack-objects' '
|
|||
'
|
||||
|
||||
test_expect_success 'verify multi-pack-index with 64-bit offsets' '
|
||||
git multi-pack-index verify --object-dir=objects64
|
||||
git -C repo64 multi-pack-index verify --object-dir=../objects64
|
||||
'
|
||||
|
||||
NUM_OBJECTS=63
|
||||
|
|
@ -734,7 +733,7 @@ MIDX_BYTE_LARGE_OFFSET=$(($MIDX_OFFSET_LARGE_OFFSETS + 3))
|
|||
|
||||
test_expect_success 'verify incorrect 64-bit offset' '
|
||||
corrupt_midx_and_verify $MIDX_BYTE_LARGE_OFFSET "\07" objects64 \
|
||||
"incorrect object offset"
|
||||
"incorrect object offset" "git -C repo64 multi-pack-index verify --object-dir=../objects64"
|
||||
'
|
||||
|
||||
test_expect_success 'setup expire tests' '
|
||||
|
|
|
|||
|
|
@ -3,9 +3,6 @@
|
|||
|
||||
test_description='Recursive "git fetch" for submodules'
|
||||
|
||||
GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1
|
||||
export GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB
|
||||
|
||||
. ./test-lib.sh
|
||||
|
||||
pwd=$(pwd)
|
||||
|
|
|
|||
|
|
@ -5,9 +5,6 @@ test_description='test push with submodules'
|
|||
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
||||
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||
|
||||
GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1
|
||||
export GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB
|
||||
|
||||
. ./test-lib.sh
|
||||
|
||||
test_expect_success setup '
|
||||
|
|
|
|||
|
|
@ -5,9 +5,6 @@ test_description='pushing to a repository using push options'
|
|||
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
||||
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||
|
||||
GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1
|
||||
export GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB
|
||||
|
||||
. ./test-lib.sh
|
||||
|
||||
mk_repo_pair () {
|
||||
|
|
|
|||
|
|
@ -2,9 +2,6 @@
|
|||
|
||||
test_description='pull can handle submodules'
|
||||
|
||||
GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1
|
||||
export GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB
|
||||
|
||||
. ./test-lib.sh
|
||||
. "$TEST_DIRECTORY"/lib-submodule-update.sh
|
||||
|
||||
|
|
|
|||
|
|
@ -5,9 +5,6 @@ test_description='merging with submodules'
|
|||
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
||||
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||
|
||||
GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1
|
||||
export GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB
|
||||
|
||||
. ./test-lib.sh
|
||||
|
||||
#
|
||||
|
|
|
|||
|
|
@ -12,9 +12,6 @@ The test setup uses a sparse checkout, however the same scenario can be set up
|
|||
also by committing .gitmodules and then just removing it from the filesystem.
|
||||
'
|
||||
|
||||
GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1
|
||||
export GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB
|
||||
|
||||
. ./test-lib.sh
|
||||
|
||||
test_expect_success 'setup' '
|
||||
|
|
|
|||
|
|
@ -9,9 +9,6 @@ submodules.
|
|||
TEST_CREATE_REPO_NO_TEMPLATE=1
|
||||
. ./test-lib.sh
|
||||
|
||||
GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1
|
||||
export GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB
|
||||
|
||||
test_expect_success 'setup directory structure and submodule' '
|
||||
echo "(1|2)d(3|4)" >a &&
|
||||
mkdir b &&
|
||||
|
|
|
|||
|
|
@ -321,11 +321,6 @@ const char **tmp_objdir_env(const struct tmp_objdir *t)
|
|||
return t->env.v;
|
||||
}
|
||||
|
||||
void tmp_objdir_add_as_alternate(const struct tmp_objdir *t)
|
||||
{
|
||||
odb_add_to_alternates_memory(t->repo->objects, t->path.buf);
|
||||
}
|
||||
|
||||
struct odb_source *tmp_objdir_replace_primary_odb(struct tmp_objdir *t,
|
||||
int will_destroy)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -55,12 +55,6 @@ int tmp_objdir_destroy(struct tmp_objdir *);
|
|||
*/
|
||||
void tmp_objdir_discard_objects(struct tmp_objdir *);
|
||||
|
||||
/*
|
||||
* Add the temporary object directory as an alternate object store in the
|
||||
* current process.
|
||||
*/
|
||||
void tmp_objdir_add_as_alternate(const struct tmp_objdir *);
|
||||
|
||||
/*
|
||||
* Replaces the writable object store in the current process with the temporary
|
||||
* object directory and makes the former main object store an alternate.
|
||||
|
|
|
|||
|
|
@ -416,7 +416,8 @@ static void report_collided_checkout(struct index_state *index)
|
|||
string_list_clear(&list, 0);
|
||||
}
|
||||
|
||||
static int must_checkout(const struct cache_entry *ce)
|
||||
static int must_checkout(const struct cache_entry *ce,
|
||||
void *cb_data UNUSED)
|
||||
{
|
||||
return ce->ce_flags & CE_UPDATE;
|
||||
}
|
||||
|
|
@ -477,7 +478,7 @@ static int check_updates(struct unpack_trees_options *o,
|
|||
* Prefetch the objects that are to be checked out in the loop
|
||||
* below.
|
||||
*/
|
||||
prefetch_cache_entries(index, must_checkout);
|
||||
prefetch_cache_entries(index, must_checkout, NULL);
|
||||
|
||||
get_parallel_checkout_configs(&pc_workers, &pc_threshold);
|
||||
|
||||
|
|
@ -487,7 +488,7 @@ static int check_updates(struct unpack_trees_options *o,
|
|||
for (i = 0; i < index->cache_nr; i++) {
|
||||
struct cache_entry *ce = index->cache[i];
|
||||
|
||||
if (must_checkout(ce)) {
|
||||
if (must_checkout(ce, NULL)) {
|
||||
size_t last_pc_queue_size = pc_queue_size();
|
||||
|
||||
if (ce->ce_flags & CE_WT_REMOVE)
|
||||
|
|
@ -2086,7 +2087,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
|
|||
}
|
||||
|
||||
if (!o->skip_cache_tree_update &&
|
||||
!cache_tree_fully_valid(o->internal.result.cache_tree))
|
||||
!cache_tree_fully_valid(the_repository, o->internal.result.cache_tree))
|
||||
cache_tree_update(&o->internal.result,
|
||||
WRITE_TREE_SILENT |
|
||||
WRITE_TREE_REPAIR);
|
||||
|
|
|
|||
Loading…
Reference in New Issue