Skip to content

Commit

Permalink
submodule: remove the per-repo cache
Browse files Browse the repository at this point in the history
Having this cache and giving them out goes against our multithreading
guarantees and it makes it impossible to use submodules in a
multi-threaded environment, as any thread can ask for a refresh which
may reallocate some string in the submodule struct which we've accessed
in a different one via a getter.

This makes the submodules behave more like remotes, where each object is
created upon request and not shared except explicitly by the user. This
means that some tests won't pass yet, as they assume they can affect the
submodule objects in the cache and that will affect later operations.
  • Loading branch information
carlosmn committed Jun 22, 2015
1 parent 0c94deb commit dfda2f6
Show file tree
Hide file tree
Showing 7 changed files with 270 additions and 576 deletions.
8 changes: 1 addition & 7 deletions src/checkout.c
Original file line number Diff line number Diff line change
Expand Up @@ -1860,11 +1860,6 @@ static int checkout_create_submodules(
git_diff_delta *delta;
size_t i;

/* initial reload of submodules if .gitmodules was changed */
if (data->reload_submodules &&
(error = git_submodule_reload_all(data->repo, 1)) < 0)
return error;

git_vector_foreach(&data->diff->deltas, i, delta) {
if (actions[i] & CHECKOUT_ACTION__DEFER_REMOVE) {
/* this has a blocker directory that should only be removed iff
Expand All @@ -1885,8 +1880,7 @@ static int checkout_create_submodules(
}
}

/* final reload once submodules have been updated */
return git_submodule_reload_all(data->repo, 1);
return 0;
}

static int checkout_lookup_head_tree(git_tree **out, git_repository *repo)
Expand Down
1 change: 0 additions & 1 deletion src/repository.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ void git_repository__cleanup(git_repository *repo)

git_cache_clear(&repo->objects);
git_attr_cache_flush(repo);
git_submodule_cache_free(repo);

set_config(repo, NULL);
set_index(repo, NULL);
Expand Down
1 change: 0 additions & 1 deletion src/repository.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ struct git_repository {
git_refdb *_refdb;
git_config *_config;
git_index *_index;
git_submodule_cache *_submodules;

git_cache objects;
git_attr_cache *attrcache;
Expand Down
Loading

0 comments on commit dfda2f6

Please sign in to comment.