summaryrefslogtreecommitdiff
path: root/path.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-12-19 14:45:37 -0800
committerJunio C Hamano <gitster@pobox.com>2016-12-19 14:45:37 -0800
commit4833b7ec2597e65285b4d35337db48f441e9b9d7 (patch)
treeaa8dad8ed52942077e1357da8cbbe2643ac34bf0 /path.c
parent0cfdda3479443c2c9282547796b59c4e727b5343 (diff)
parent7814fbe3f1e7cea1a675408df7b5dd1f5be731cc (diff)
downloadgit-4833b7ec2597e65285b4d35337db48f441e9b9d7.tar.gz
Merge branch 'js/normalize-path-copy-ceil'
A pathname that begins with "//" or "\\" on Windows is special but path normalization logic was unaware of it. * js/normalize-path-copy-ceil: normalize_path_copy(): fix pushing to //server/share/dir on Windows
Diffstat (limited to 'path.c')
-rw-r--r--path.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/path.c b/path.c
index 52d889c88e..efcedafba6 100644
--- a/path.c
+++ b/path.c
@@ -991,7 +991,7 @@ const char *remove_leading_path(const char *in, const char *prefix)
*
* Performs the following normalizations on src, storing the result in dst:
* - Ensures that components are separated by '/' (Windows only)
- * - Squashes sequences of '/'.
+ * - Squashes sequences of '/' except "//server/share" on Windows
* - Removes "." components.
* - Removes ".." components, and the components the precede them.
* Returns failure (non-zero) if a ".." component appears as first path
@@ -1014,17 +1014,22 @@ const char *remove_leading_path(const char *in, const char *prefix)
int normalize_path_copy_len(char *dst, const char *src, int *prefix_len)
{
char *dst0;
- int i;
+ const char *end;
- for (i = has_dos_drive_prefix(src); i > 0; i--)
- *dst++ = *src++;
+ /*
+ * Copy initial part of absolute path: "/", "C:/", "//server/share/".
+ */
+ end = src + offset_1st_component(src);
+ while (src < end) {
+ char c = *src++;
+ if (is_dir_sep(c))
+ c = '/';
+ *dst++ = c;
+ }
dst0 = dst;
- if (is_dir_sep(*src)) {
- *dst++ = '/';
- while (is_dir_sep(*src))
- src++;
- }
+ while (is_dir_sep(*src))
+ src++;
for (;;) {
char c = *src;