Skip to content

Commit e46249f

Browse files
committed
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
2 parents 51cf315 + 85fe0e8 commit e46249f

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

config.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,8 @@ static int include_by_branch(const char *cond, size_t cond_len)
275275
int flags;
276276
int ret;
277277
struct strbuf pattern = STRBUF_INIT;
278-
const char *refname = resolve_ref_unsafe("HEAD", 0, NULL, &flags);
278+
const char *refname = !the_repository || !the_repository->gitdir ?
279+
NULL : resolve_ref_unsafe("HEAD", 0, NULL, &flags);
279280
const char *shortname;
280281

281282
if (!refname || !(flags & REF_ISSYMREF) ||

t/t1309-early-config.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,9 @@ test_expect_failure 'ignore .git/ with invalid config' '
8989
test_with_config "["
9090
'
9191

92+
test_expect_success 'early config and onbranch' '
93+
echo "[broken" >broken &&
94+
test_with_config "[includeif \"onbranch:refs/heads/master\"]path=../broken"
95+
'
96+
9297
test_done

0 commit comments

Comments
 (0)