summaryrefslogtreecommitdiff
path: root/t/t1309-early-config.sh
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2019-07-31 20:06:42 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-07-31 22:20:56 (GMT)
commit85fe0e800ca6acc690fc4c55931a200b4679211e (patch)
tree406c600df7be0cc75bfb3a654c30be9bfcf7e342 /t/t1309-early-config.sh
parentf36d08d72e7f68f880f8c1d7646cb3809c820485 (diff)
downloadgit-85fe0e800ca6acc690fc4c55931a200b4679211e.zip
git-85fe0e800ca6acc690fc4c55931a200b4679211e.tar.gz
git-85fe0e800ca6acc690fc4c55931a200b4679211e.tar.bz2
config: work around bug with includeif:onbranch and early config
Since 07b2c0eacac (config: learn the "onbranch:" includeIf condition, 2019-06-05), there is a potential catch-22 in the early config path: if the `include.onbranch:` feature is used, Git assumes that the Git directory has been initialized already. However, in the early config code path that is not true. One way to trigger this is to call the following commands in any repository: git config includeif.onbranch:refs/heads/master.path broken git help -a The symptom triggered by the `git help -a` invocation reads like this: BUG: refs.c:1851: attempting to get main_ref_store outside of repository Let's work around this, simply by ignoring the `includeif.onbranch:` setting when parsing the config when the ref store has not been initialized (yet). Technically, there is a way to solve this properly: teach the refs machinery to initialize the ref_store from a given gitdir/commondir pair (which we _do_ have in the early config code path), and then use that in `include_by_branch()`. This, however, is a pretty involved project, and we're already in the feature freeze for Git v2.23.0. Note: when calling above-mentioned two commands _outside_ of any Git worktree (passing the `--global` flag to `git config`, as there is obviously no repository config available), at the point when `include_by_branch()` is called, `the_repository` is `NULL`, therefore we have to be extra careful not to dereference it in that case. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1309-early-config.sh')
-rwxr-xr-xt/t1309-early-config.sh5
1 files changed, 5 insertions, 0 deletions
diff --git a/t/t1309-early-config.sh b/t/t1309-early-config.sh
index 413642a..0c37e71 100755
--- a/t/t1309-early-config.sh
+++ b/t/t1309-early-config.sh
@@ -89,4 +89,9 @@ test_expect_failure 'ignore .git/ with invalid config' '
test_with_config "["
'
+test_expect_success 'early config and onbranch' '
+ echo "[broken" >broken &&
+ test_with_config "[includeif \"onbranch:refs/heads/master\"]path=../broken"
+'
+
test_done