diff --git a/refs.c b/refs.c index 9b56fa9b81..4a44e44b6a 100644 --- a/refs.c +++ b/refs.c @@ -1654,6 +1654,9 @@ struct ref_store *get_main_ref_store(struct repository *r) if (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); return r->refs; }