mirror of
https://github.com/git/git.git
synced 2026-02-03 06:21:39 +00:00
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 <johannes.schindelin@gmx.de>
This commit is contained in:
4
config.c
4
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)
|
||||
|
||||
Reference in New Issue
Block a user