I actually stumbled over this while rebasing the VFS for Git patches, in relation with the pre-command hook that we still support there (we're slowly migrating toward Trace2, of course). Once I figured out what the problem was, I hunted for a way to trigger this bug in plain Git, and git help -a is the one I settled on. It had to be a command that uses the early config machinery (and git help -a uses it to list all aliases), and it had to be a command that does not discover a .git directory automatically (cmd_help is listed without any flags in git.c, so: check). Of course, part of me wants to just go and dig into the refs part of the code to introduce an equivalent to the "early config" machinery (calling it "early ref store"), but: 1. We're really in feature freeze, and I want this bug fix to go into v2.23.0. 2. It is actually a pretty obscure thing to want: a branch-dependent config that is used that early that the Git directory was not yet discovered. I could imagine that some power user wants to play some games at some stage, say, with the pager depending on the name of the current branch, but even then, to run into the issue with this here patch where it simply ignores the includeif.onbranch: setting in the early config code path, a command has to be run that does not immediately set up the_repository->gitdir but still wants to use the configured pager. So yes, this patch introduces a known issue, but it does fix a BUG() where no bug should be reported. Johannes Schindelin (1): config: work around bug with includeif:onbranch and early config config.c | 3 ++- t/t1309-early-config.sh | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) base-commit: 026dd738a6e5f1e42ef0f390feacb5ed6acc4ee8 Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-300%2Fdscho%2Fonbranch-and-early-config-v1 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-300/dscho/onbranch-and-early-config-v1 Pull-Request: https://github.com/gitgitgadget/git/pull/300 -- gitgitgadget