Skip to content

Commit

Permalink
Merge branch 'js/bs-is-a-dir-sep-on-windows'
Browse files Browse the repository at this point in the history
"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
  • Loading branch information
gitster committed Jun 2, 2017
2 parents 0339965 + d9244ec commit 7d26aa3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion compat/mingw.h
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,11 @@ HANDLE winansi_get_osfhandle(int fd);
(isalpha(*(path)) && (path)[1] == ':' ? 2 : 0)
int mingw_skip_dos_drive_prefix(char **path);
#define skip_dos_drive_prefix mingw_skip_dos_drive_prefix
#define is_dir_sep(c) ((c) == '/' || (c) == '\\')
static inline int mingw_is_dir_sep(int c)
{
return c == '/' || c == '\\';
}
#define is_dir_sep mingw_is_dir_sep
static inline char *mingw_find_last_dir_sep(const char *path)
{
char *ret = NULL;
Expand Down
7 changes: 6 additions & 1 deletion remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,12 @@ static int valid_remote_nick(const char *name)
{
if (!name[0] || is_dot_or_dotdot(name))
return 0;
return !strchr(name, '/'); /* no slash */

/* remote nicknames cannot contain slashes */
while (*name)
if (is_dir_sep(*name++))
return 0;
return 1;
}

const char *remote_for_branch(struct branch *branch, int *explicit)
Expand Down

0 comments on commit 7d26aa3

Please sign in to comment.