From 2db7919fff6c7ca74753ecfc63cf842bbc819882 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 24 Feb 2016 12:47:18 +0100 Subject: [PATCH] squash! config.c: create missing parent directories when modifying config files We *must not* create the leading directories when locking a config file. It is the caller's responsibility to ensure that the directory exists, just like it is the caller's responsibility to call `git init` before running repository operations. Point in case: if we simply create all leading directories, calling `git config user.name me` *outside* of a Git worktree will *create* .git/! This fixes 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 --- config.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/config.c b/config.c index f8eb6d4208..a7dbea0dd4 100644 --- a/config.c +++ b/config.c @@ -1951,10 +1951,6 @@ static int lock_config_file(const char *config_filename, { int fd; - /* make sure the parent directory exists */ - if (safe_create_leading_directories_const(config_filename)) - return error("could not create parent directory of %s", - config_filename); *result = xcalloc(1, sizeof(struct lock_file)); fd = hold_lock_file_for_update(*result, config_filename, 0); if (fd < 0)