config.c: fix writing config files on Windows network shares

Renaming to an existing file doesn't work on Windows network shares if the
target file is open.

munmap() the old config file before commit_lock_file.

Signed-off-by: Karsten Blees <blees@dcon.de>
Acked-by: Jeff King <peff@peff.net>
Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Karsten Blees 2015-06-30 16:34:13 +02:00 committed by Junio C Hamano
parent 351d06df51
commit 7a64592cf8

View File

@ -2116,6 +2116,9 @@ int git_config_set_multivar_in_file(const char *config_filename,
contents_sz - copy_begin) < contents_sz - copy_begin) <
contents_sz - copy_begin) contents_sz - copy_begin)
goto write_err_out; goto write_err_out;
munmap(contents, contents_sz);
contents = NULL;
} }
if (commit_lock_file(lock) < 0) { if (commit_lock_file(lock) < 0) {