Skip to content

Commit e6f80ae

Browse files
committed
Merge branch 'js/bs-is-a-dir-sep-on-windows' into maint
"foo\bar\baz" in "git fetch foo\bar\baz", even though there is no slashes in it, cannot be a nickname for a remote on Windows, as that is likely to be a pathname on a local filesystem. * js/bs-is-a-dir-sep-on-windows: Windows: do not treat a path with backslashes as a remote's nick name mingw.h: permit arguments with side effects for is_dir_sep
2 parents a07148d + d9244ec commit e6f80ae

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

compat/mingw.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,11 @@ HANDLE winansi_get_osfhandle(int fd);
398398
(isalpha(*(path)) && (path)[1] == ':' ? 2 : 0)
399399
int mingw_skip_dos_drive_prefix(char **path);
400400
#define skip_dos_drive_prefix mingw_skip_dos_drive_prefix
401-
#define is_dir_sep(c) ((c) == '/' || (c) == '\\')
401+
static inline int mingw_is_dir_sep(int c)
402+
{
403+
return c == '/' || c == '\\';
404+
}
405+
#define is_dir_sep mingw_is_dir_sep
402406
static inline char *mingw_find_last_dir_sep(const char *path)
403407
{
404408
char *ret = NULL;

remote.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,12 @@ static int valid_remote_nick(const char *name)
649649
{
650650
if (!name[0] || is_dot_or_dotdot(name))
651651
return 0;
652-
return !strchr(name, '/'); /* no slash */
652+
653+
/* remote nicknames cannot contain slashes */
654+
while (*name)
655+
if (is_dir_sep(*name++))
656+
return 0;
657+
return 1;
653658
}
654659

655660
const char *remote_for_branch(struct branch *branch, int *explicit)

0 commit comments

Comments
 (0)