@matheusbsbs / matheus-bagliano / commits / b248e95096
Fork 0

Fix 'clone' failure at DOS root directory.

Cloning via relative path fails for a project residing immediately under the root directory of a DOS drive. For instance, for project c:/foo, issuing "cd c:/" followed by "git clone foo bar" fails with error "Unable to find remote helper for 'c'". The problem is caused by make_nonrelative_path() incorrectly returning c://foo rather than c:/foo for input "foo". The bogus path c://foo is misinterpreted by transport_get() as a URL with unrecognized protocol "c", hence the missing remote helper error. Fix make_nonrelative_path() to return c:/foo rather than c://foo (and /foo rather than //foo on Unix). Resolves msysgit issue #501 [1] [PT: squashed in changes requested by Junio [2][3]] [1] http://code.google.com/p/msysgit/issues/detail?id=501 [2] http://marc.info/?l=git&m=128570102331652&w=2 [3] http://marc.info/?l=git&m=128573246704862&w=2 Acked-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>

Eric Sunshine committed Jul 6, 2010 at 21:48 UTC b248e950966769f5f981321ea9d12f2b238c978c
1 file changed +5 -1
abspath.c
+5 -1
@@ -108,10 +108,14 @@ const char *make_nonrelative_path(const char *path)
108 if (strlcpy(buf, path, PATH_MAX) >= PATH_MAX)
109 die("Too long path: %.*s", 60, path);
110 } else {
111 + size_t len;
112 + const char *fmt;
113 const char *cwd = get_pwd_cwd();
114 if (!cwd)
115 die_errno("Cannot determine the current working directory");
114 - if (snprintf(buf, PATH_MAX, "%s/%s", cwd, path) >= PATH_MAX)
116 + len = strlen(cwd);
117 + fmt = (len > 0 && is_dir_sep(cwd[len-1])) ? "%s%s" : "%s/%s";
118 + if (snprintf(buf, PATH_MAX, fmt, cwd, path) >= PATH_MAX)
119 die("Too long path: %.*s", 60, path);
120 }
121 return buf;