[PATCH] git config: do not create .git/ if it does not exist yet
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Feb 24, 2016, 07:47 UTC
- Message-ID
- <c4027d758b0914dbc2e1ff5df344b0669aac4447.1456299545.git.johannes.schindelin@gmx.de>
It is a pilot error to call `git config section.key value` outside of any Git worktree.
Let's report that error instead of creating the .git/ directory and writing a fresh config into it.
This addresses https://github.com/git-for-windows/git/issues/643 and https://groups.google.com/forum/#!topic/git-for-windows/fVRdnDIKVuw
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> ---
I cannot think of a way how to test this: all of the regression tests run inside Git's own worktree, and we cannot even assume that /tmp/ is outside of a worktree (or that it exists).
builtin/config.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/builtin/config.c b/builtin/config.c index adc7727..78aab95 100644 --- a/builtin/config.c +++ b/builtin/config.c @@ -352,6 +352,9 @@ static int get_colorbool(const char *var, int print) static void check_write(void) { + if (!given_config_source.file && !startup_info->have_repository) + die("not in a git directory"); + if (given_config_source.use_stdin) die("writing to stdin is not supported");
-- 2.7.2.windows.1.2.gbc859c8