Merge branch 'sb/object-store-replace'

Hotfix.

* sb/object-store-replace:
  get_main_ref_store: BUG() when outside a repository
  object.c: clear replace map before freeing it
  replace-object.c: remove the_repository from prepare_replace_object
  object.c: free replace map in raw_object_store_clear
This commit is contained in:
Junio C Hamano 2018-05-23 14:38:09 +09:00
commit a2cec42213
3 changed files with 7 additions and 1 deletions

View File

@ -481,6 +481,9 @@ void raw_object_store_clear(struct raw_object_store *o)
FREE_AND_NULL(o->objectdir); FREE_AND_NULL(o->objectdir);
FREE_AND_NULL(o->alternate_db); FREE_AND_NULL(o->alternate_db);
oidmap_free(o->replace_map, 1);
FREE_AND_NULL(o->replace_map);
free_alt_odbs(o); free_alt_odbs(o);
o->alt_odb_tail = NULL; o->alt_odb_tail = NULL;

3
refs.c
View File

@ -1668,6 +1668,9 @@ struct ref_store *get_main_ref_store(struct repository *r)
if (r->refs) if (r->refs)
return r->refs; return r->refs;
if (!r->gitdir)
BUG("attempting to get main_ref_store outside of repository");
r->refs = ref_store_init(r->gitdir, REF_STORE_ALL_CAPS); r->refs = ref_store_init(r->gitdir, REF_STORE_ALL_CAPS);
return r->refs; return r->refs;
} }

View File

@ -37,7 +37,7 @@ static void prepare_replace_object(struct repository *r)
return; return;
r->objects->replace_map = r->objects->replace_map =
xmalloc(sizeof(*the_repository->objects->replace_map)); xmalloc(sizeof(*r->objects->replace_map));
oidmap_init(r->objects->replace_map, 0); oidmap_init(r->objects->replace_map, 0);
for_each_replace_ref(r, register_replace_ref, NULL); for_each_replace_ref(r, register_replace_ref, NULL);