Skip to content

Commit e5b3134

Browse files
j6tgitster
authored andcommitted
mingw_fopen: report ENOENT for invalid file names
On Windows, certain characters are prohibited in file names, most prominently the colon. When fopen() is called with such an invalid file name, the underlying Windows API actually reports a particular error, but since there is no suitable errno value, this error is translated to EINVAL. Detect the case and report ENOENT instead. Signed-off-by: Johannes Sixt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 13b57da commit e5b3134

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

compat/mingw.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,8 @@ FILE *mingw_fopen (const char *filename, const char *otype)
423423
return NULL;
424424
}
425425
file = _wfopen(wfilename, wotype);
426+
if (!file && GetLastError() == ERROR_INVALID_NAME)
427+
errno = ENOENT;
426428
if (file && hide && set_hidden_flag(wfilename, 1))
427429
warning("could not mark '%s' as hidden.", filename);
428430
return file;

t/t5580-clone-push-unc.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ test_expect_success push '
4545
test "$rev" = "$(git rev-parse --verify refs/heads/to-push)"
4646
'
4747

48-
test_expect_failure 'remote nick cannot contain backslashes' '
48+
test_expect_success 'remote nick cannot contain backslashes' '
4949
BACKSLASHED="$(pwd | tr / \\\\)" &&
5050
git ls-remote "$BACKSLASHED" >out 2>err &&
5151
test_i18ngrep ! "unable to access" err

0 commit comments

Comments
 (0)