Merge branch 'jk/repo-init-cleanup'
authorJunio C Hamano <gitster@pobox.com>
Mon, 9 Sep 2019 19:26:35 +0000 (12:26 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 9 Sep 2019 19:26:35 +0000 (12:26 -0700)
Further clean-up of the initialization code.

* jk/repo-init-cleanup:
config: stop checking whether the_repository is NULL
common-main: delay trace2 initialization
t1309: use short branch name in includeIf.onbranch test

common-main.c
config.c
t/t1309-early-config.sh
index 582a7b18869fb80c94b3a0057e4cb9ced4c6f1c2..71e21dd20a3b141bed0d37512cdc9196321dc315 100644 (file)
@@ -39,16 +39,16 @@ int main(int argc, const char **argv)
 
        git_resolve_executable_dir(argv[0]);
 
-       trace2_initialize();
-       trace2_cmd_start(argv);
-       trace2_collect_process_info(TRACE2_PROCESS_INFO_STARTUP);
-
        git_setup_gettext();
 
        initialize_the_repository();
 
        attr_start();
 
+       trace2_initialize();
+       trace2_cmd_start(argv);
+       trace2_collect_process_info(TRACE2_PROCESS_INFO_STARTUP);
+
        result = cmd_main(argc, argv);
 
        trace2_cmd_exit(result);
index 3900e4947be92b916ed9b531eb455e8f856105dc..cc637363bbae10f1b87b5b7ab0bd015e49cb56b8 100644 (file)
--- a/config.c
+++ b/config.c
@@ -275,7 +275,7 @@ static int include_by_branch(const char *cond, size_t cond_len)
        int flags;
        int ret;
        struct strbuf pattern = STRBUF_INIT;
-       const char *refname = !the_repository || !the_repository->gitdir ?
+       const char *refname = !the_repository->gitdir ?
                NULL : resolve_ref_unsafe("HEAD", 0, NULL, &flags);
        const char *shortname;
 
index 0c37e7180d1cde57d49c12deb28239c509d9207d..3a0de0ddaa553e82b7db8594f4c45489237fb7db 100755 (executable)
@@ -91,7 +91,12 @@ test_expect_failure 'ignore .git/ with invalid config' '
 
 test_expect_success 'early config and onbranch' '
        echo "[broken" >broken &&
-       test_with_config "[includeif \"onbranch:refs/heads/master\"]path=../broken"
+       test_with_config "[includeif \"onbranch:master\"]path=../broken"
+'
+
+test_expect_success 'onbranch config outside of git repo' '
+       test_config_global includeIf.onbranch:master.path non-existent &&
+       nongit git help
 '
 
 test_done