Merge branch 'ps/reftable-windows-unlink-fix'
Portability fix. * ps/reftable-windows-unlink-fix: reftable: ignore file-in-use errors when unlink(3p) fails on Windowsmaint
commit
139d703511
|
@ -201,8 +201,12 @@ int uname(struct utsname *buf);
|
|||
* replacements of existing functions
|
||||
*/
|
||||
|
||||
int mingw_unlink(const char *pathname);
|
||||
#define unlink mingw_unlink
|
||||
int mingw_unlink(const char *pathname, int handle_in_use_error);
|
||||
#ifdef MINGW_DONT_HANDLE_IN_USE_ERROR
|
||||
# define unlink(path) mingw_unlink(path, 0)
|
||||
#else
|
||||
# define unlink(path) mingw_unlink(path, 1)
|
||||
#endif
|
||||
|
||||
int mingw_rmdir(const char *path);
|
||||
#define rmdir mingw_rmdir
|
||||
|
|
|
@ -302,7 +302,7 @@ static wchar_t *normalize_ntpath(wchar_t *wbuf)
|
|||
return wbuf;
|
||||
}
|
||||
|
||||
int mingw_unlink(const char *pathname)
|
||||
int mingw_unlink(const char *pathname, int handle_in_use_error)
|
||||
{
|
||||
int ret, tries = 0;
|
||||
wchar_t wpathname[MAX_PATH];
|
||||
|
@ -317,6 +317,9 @@ int mingw_unlink(const char *pathname)
|
|||
while ((ret = _wunlink(wpathname)) == -1 && tries < ARRAY_SIZE(delay)) {
|
||||
if (!is_file_in_use_error(GetLastError()))
|
||||
break;
|
||||
if (!handle_in_use_error)
|
||||
return ret;
|
||||
|
||||
/*
|
||||
* We assume that some other process had the source or
|
||||
* destination file open at the wrong moment and retry.
|
||||
|
|
|
@ -11,6 +11,7 @@ https://developers.google.com/open-source/licenses/bsd
|
|||
|
||||
/* This header glues the reftable library to the rest of Git */
|
||||
|
||||
#define MINGW_DONT_HANDLE_IN_USE_ERROR
|
||||
#include "compat/posix.h"
|
||||
#include "compat/zlib-compat.h"
|
||||
|
||||
|
|
Loading…
Reference in New Issue