Commit 38160bc
config.c: create missing parent directories when modifying config files
'git config' (--add / --unset etc.) automatically creates missing config
files. However, it fails with a misleading error message "could not lock
config file" if the parent directory doesn't exist.
Also create missing parent directories.
This is particularly important when calling
git config -f /non/existing/directory/config ...
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 git-for-windows#643 and
https://groups.google.com/forum/#!topic/git-for-windows/fVRdnDIKVuw
[jes: prevented bogus .git/ directories from being created]
Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>1 parent 5141741 commit 38160bc
1 file changed
Lines changed: 17 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1952 | 1952 | | |
1953 | 1953 | | |
1954 | 1954 | | |
| 1955 | + | |
| 1956 | + | |
| 1957 | + | |
| 1958 | + | |
| 1959 | + | |
| 1960 | + | |
| 1961 | + | |
| 1962 | + | |
| 1963 | + | |
| 1964 | + | |
| 1965 | + | |
| 1966 | + | |
| 1967 | + | |
| 1968 | + | |
1955 | 1969 | | |
1956 | 1970 | | |
1957 | 1971 | | |
| |||
2003 | 2017 | | |
2004 | 2018 | | |
2005 | 2019 | | |
2006 | | - | |
2007 | | - | |
| 2020 | + | |
2008 | 2021 | | |
2009 | | - | |
2010 | 2022 | | |
2011 | 2023 | | |
2012 | 2024 | | |
| |||
2305 | 2317 | | |
2306 | 2318 | | |
2307 | 2319 | | |
2308 | | - | |
2309 | | - | |
2310 | | - | |
2311 | | - | |
| 2320 | + | |
| 2321 | + | |
2312 | 2322 | | |
2313 | | - | |
2314 | 2323 | | |
2315 | 2324 | | |
2316 | 2325 | | |
| |||
0 commit comments