Subject: Re: BUG: refs.c:1933: reference backend is unknown

From: shejialuo <[email-masked]>
Date: Sun, 22 Sep 2024 14:51:30 +0800

On Sat, Sep 21, 2024 at 11:22:04PM +0200, René Scharfe wrote:

[snip]

> I wonder if the BUG at refs.c:1933 should just be turned into a die().
> Or should ref_store_init() return NULL (or some other value indicating
> an error) and all callers need to be changed to deal with that?
> 
> Simply checking whether --git-dir points to an actual repo earlier is
> tempting, but would leave the case of it disappearing after the check
> unhandled.

>From my perspective, it is not suitable to change the "refs.c". I guess
the reason why Patrick uses the "BUG()" is that it's an internal
implementation and we should tell the developer something is wrong.

In this case, because we use "include.onbranch" configuration, the
"config.c::include_by_branch" will use "refsc::get_main_ref_store" to
get the refname.

However, the repo does not exist, so we cannot find any ref backend. The
main problem is that we never check whether "the_repository->gitdir" is
a git directory in "config.c::include_by_branch". So, we do not need to
check the value of the option "--git-dir".

Thanks,
Jialuo