diff options
author | Junio C Hamano <gitster@pobox.com> | 2019-08-02 13:12:02 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-08-02 13:12:02 -0700 |
commit | e46249f73ebddca06cf16c01e8de1f310360c856 (patch) | |
tree | dd8f3bd4c4b56cd5b24ba24d281b037a08eb4d77 | |
parent | Merge branch 'jk/repack-silence-auto-bitmap-warning' (diff) | |
parent | config: work around bug with includeif:onbranch and early config (diff) | |
download | tgif-e46249f73ebddca06cf16c01e8de1f310360c856.tar.xz |
Merge branch 'js/early-config-with-onbranch'
The recently added [includeif "onbranch:branch"] feature does not
work well with an early config mechanism, as it attempts to find
out what branch we are on before we even haven't located the git
repository. The inclusion during early config scan is ignored to
work around this issue.
* js/early-config-with-onbranch:
config: work around bug with includeif:onbranch and early config
-rw-r--r-- | config.c | 3 | ||||
-rwxr-xr-x | t/t1309-early-config.sh | 5 |
2 files changed, 7 insertions, 1 deletions
@@ -275,7 +275,8 @@ static int include_by_branch(const char *cond, size_t cond_len) int flags; int ret; struct strbuf pattern = STRBUF_INIT; - const char *refname = resolve_ref_unsafe("HEAD", 0, NULL, &flags); + const char *refname = !the_repository || !the_repository->gitdir ? + NULL : resolve_ref_unsafe("HEAD", 0, NULL, &flags); const char *shortname; if (!refname || !(flags & REF_ISSYMREF) || diff --git a/t/t1309-early-config.sh b/t/t1309-early-config.sh index 413642aa56..0c37e7180d 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 |