Hopefully these patches will lead to something that we can integrate, and that eventually will make Git's startup sequence much less surprising. The idea here is to discover the .git/ directory gently (i.e. without changing the current working directory), and to use it to read the .git/config file early, before we actually called setup_git_directory() (if we ever do that). Notes: - I find the diff pretty ugly: I wish there was a more elegant way to *disable* discovery of .git/ *just* for `init` and `clone`. I considered a function `about_to_create_git_dir()` that is called in a hard-coded manner *only* for `init` and `clone`, but that would introduce another magic side effect, when all I want is to reduce those. - For the moment, I do not handle dashed invocations of `init` and `clone` correctly. The real problem is the continued existence of the dashed git-init and git-clone, of course. - There is still duplicated code. For the sake of this RFC, I did not address that yet. - The read_early_config() function is called multiple times, re-reading all the config files and re-discovering the .git/ directory multiple times, which is quite wasteful. For the sake of this RFC, I did not address that yet. - t7006 fails and the error message is a bit cryptic (not to mention the involved function trace, which is mind-boggling for what is supposed to be a simply, shell script-based test suite). I did not have time to look into that yet. - after discover_git_directory_gently() did its work, the code happily uses its result *only* for the current read_early_config() run, and lets setup_git_dir_gently() do the whole work *again*. For the sake of this RFC, I did not address that yet. Johannes Schindelin (7): Make read_early_config() reusable read_early_config(): avoid .git/config hack when unneeded Mark builtins that create .git/ directories read_early_config(): special-case `init` and `clone` read_early_config(): really discover .git/ WIP read_config_early(): respect ceiling directories WIP: read_early_config(): add tests builtin/am.c | 2 +- builtin/blame.c | 2 +- builtin/grep.c | 4 +- builtin/log.c | 4 +- builtin/var.c | 2 +- cache.h | 8 ++-- config.c | 110 ++++++++++++++++++++++++++++++++++++++++++++++++ diff.c | 4 +- git.c | 25 +++++------ pager.c | 44 +++---------------- t/helper/test-config.c | 15 +++++++ t/t1309-early-config.sh | 50 ++++++++++++++++++++++ 12 files changed, 209 insertions(+), 61 deletions(-) create mode 100755 t/t1309-early-config.sh base-commit: 8d7a455ed52e2a96debc080dfc011b6bb00db5d2 Published-As: https://github.com/dscho/git/releases/tag/early-config-v1 Fetch-It-Via: git fetch https://github.com/dscho/git early-config-v1 -- 2.11.0.rc3.windows.1