* [PATCH] Windows: Allow using UNC path for git repository
@ 2014-05-19 13:23 Stepan Kasal
2014-05-20 18:57 ` Junio C Hamano
0 siblings, 1 reply; 4+ messages in thread
From: Stepan Kasal @ 2014-05-19 13:23 UTC (permalink / raw)
To: GIT Mailing-list; +Cc: Erik Faye-Lund, msysGit, Cezary Zawadka, Eric Sunshine
From: Cezary Zawadka <czawadka@gmail.com>
Date: Tue, 13 Jul 2010 16:17:43 +0200
[efl: moved MinGW-specific part to compat/]
[jes: fixed compilation on non-Windows]
Eric Sunshine fixed mingw_offset_1st_component() to return consistently "foo"
for UNC "//machine/share/foo", cf
http://groups.google.com/group/msysgit/browse_thread/thread/c0af578549b5dda0
Author: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Cezary Zawadka <czawadka@gmail.com>
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Stepan Kasal <kasal@ucw.cz>
---
Hello,
this is another patch that lived in msysGit for years, at least from
Jul 13, 2010. It was there in two parts, first sketch by Cezary and
a fix from Eric Sunshine, but I decided to submit the combined
version.
Let me note that this patch should not affect any non-Windows
platform. The chnage of offset_1st_component() to a simple macro is
ok, because has_dos_drive_prefix() is 0 there.
Regards,
Stepan
cache.h | 1 -
compat/mingw.c | 24 ++++++++++++++++++++++++
compat/mingw.h | 2 ++
git-compat-util.h | 4 ++++
path.c | 7 -------
5 files changed, 30 insertions(+), 8 deletions(-)
diff --git a/cache.h b/cache.h
index ebe9a40..0961fb5 100644
--- a/cache.h
+++ b/cache.h
@@ -781,7 +781,6 @@ int normalize_path_copy(char *dst, const char *src);
int longest_ancestor_length(const char *path, struct string_list *prefixes);
char *strip_path_suffix(const char *path, const char *suffix);
int daemon_avoid_alias(const char *path);
-int offset_1st_component(const char *path);
/* object replacement */
#define LOOKUP_REPLACE_OBJECT 1
diff --git a/compat/mingw.c b/compat/mingw.c
index e9892f8..a0e13bc 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -1823,3 +1823,27 @@ pid_t waitpid(pid_t pid, int *status, int options)
errno = EINVAL;
return -1;
}
+
+int mingw_offset_1st_component(const char *path)
+{
+ int offset = 0;
+ if (has_dos_drive_prefix(path))
+ offset = 2;
+
+ /* unc paths */
+ else if (is_dir_sep(path[0]) && is_dir_sep(path[1])) {
+
+ /* skip server name */
+ char *pos = strpbrk(path + 2, "\\/");
+ if (!pos)
+ return 0; /* Error: malformed unc path */
+
+ do {
+ pos++;
+ } while (*pos && !is_dir_sep(*pos));
+
+ offset = pos - path;
+ }
+
+ return offset + is_dir_sep(path[offset]);
+}
diff --git a/compat/mingw.h b/compat/mingw.h
index e033e72..3eaf822 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -339,6 +339,8 @@ static inline char *mingw_find_last_dir_sep(const char *path)
return ret;
}
#define find_last_dir_sep mingw_find_last_dir_sep
+int mingw_offset_1st_component(const char *path);
+#define offset_1st_component mingw_offset_1st_component
#define PATH_SEP ';'
#define PRIuMAX "I64u"
#define PRId64 "I64d"
diff --git a/git-compat-util.h b/git-compat-util.h
index d493a8c..ec41cfb 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -270,6 +270,10 @@ extern char *gitbasename(char *);
#define has_dos_drive_prefix(path) 0
#endif
+#ifndef offset_1st_component
+#define offset_1st_component(path) (is_dir_sep((path)[0]))
+#endif
+
#ifndef is_dir_sep
#define is_dir_sep(c) ((c) == '/')
#endif
diff --git a/path.c b/path.c
index f9c5062..bc804a3 100644
--- a/path.c
+++ b/path.c
@@ -823,10 +823,3 @@ int daemon_avoid_alias(const char *p)
}
}
}
-
-int offset_1st_component(const char *path)
-{
- if (has_dos_drive_prefix(path))
- return 2 + is_dir_sep(path[2]);
- return is_dir_sep(path[0]);
-}
--
1.9.2.msysgit.0.490.ga07b726
--
--
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.
You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en
---
You received this message because you are subscribed to the Google Groups "msysGit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Windows: Allow using UNC path for git repository
2014-05-19 13:23 [PATCH] Windows: Allow using UNC path for git repository Stepan Kasal
@ 2014-05-20 18:57 ` Junio C Hamano
2014-05-20 19:21 ` Stepan Kasal
0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2014-05-20 18:57 UTC (permalink / raw)
To: Stepan Kasal
Cc: GIT Mailing-list, Erik Faye-Lund, msysGit, Cezary Zawadka,
Eric Sunshine
Stepan Kasal <kasal@ucw.cz> writes:
> From: Cezary Zawadka <czawadka@gmail.com>
> Date: Tue, 13 Jul 2010 16:17:43 +0200
>
> [efl: moved MinGW-specific part to compat/]
> [jes: fixed compilation on non-Windows]
>
> Eric Sunshine fixed mingw_offset_1st_component() to return consistently "foo"
> for UNC "//machine/share/foo", cf
> http://groups.google.com/group/msysgit/browse_thread/thread/c0af578549b5dda0
>
> Author: Eric Sunshine <sunshine@sunshineco.com>
> Signed-off-by: Cezary Zawadka <czawadka@gmail.com>
> Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
> Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> Signed-off-by: Stepan Kasal <kasal@ucw.cz>
> ---
>
> Hello,
> this is another patch that lived in msysGit for years, at least from
> Jul 13, 2010. It was there in two parts, first sketch by Cezary and
> a fix from Eric Sunshine, but I decided to submit the combined
> version.
>
> Let me note that this patch should not affect any non-Windows
> platform. The chnage of offset_1st_component() to a simple macro is
> ok, because has_dos_drive_prefix() is 0 there.
As I do not think anybody takes the address of the function, I agree
it should be a no-op for non-Windows platform.
It would be nice if somebody in the S-o-b chain can double-check
that the "combined" version is sane. I didn't read the mingw.c part
carefully enough for me to say returning 0 upon error is sane with
confidence, for example.
Thanks.
> Regards,
> Stepan
>
> cache.h | 1 -
> compat/mingw.c | 24 ++++++++++++++++++++++++
> compat/mingw.h | 2 ++
> git-compat-util.h | 4 ++++
> path.c | 7 -------
> 5 files changed, 30 insertions(+), 8 deletions(-)
>
> diff --git a/cache.h b/cache.h
> index ebe9a40..0961fb5 100644
> --- a/cache.h
> +++ b/cache.h
> @@ -781,7 +781,6 @@ int normalize_path_copy(char *dst, const char *src);
> int longest_ancestor_length(const char *path, struct string_list *prefixes);
> char *strip_path_suffix(const char *path, const char *suffix);
> int daemon_avoid_alias(const char *path);
> -int offset_1st_component(const char *path);
>
> /* object replacement */
> #define LOOKUP_REPLACE_OBJECT 1
> diff --git a/compat/mingw.c b/compat/mingw.c
> index e9892f8..a0e13bc 100644
> --- a/compat/mingw.c
> +++ b/compat/mingw.c
> @@ -1823,3 +1823,27 @@ pid_t waitpid(pid_t pid, int *status, int options)
> errno = EINVAL;
> return -1;
> }
> +
> +int mingw_offset_1st_component(const char *path)
> +{
> + int offset = 0;
> + if (has_dos_drive_prefix(path))
> + offset = 2;
> +
> + /* unc paths */
> + else if (is_dir_sep(path[0]) && is_dir_sep(path[1])) {
> +
> + /* skip server name */
> + char *pos = strpbrk(path + 2, "\\/");
> + if (!pos)
> + return 0; /* Error: malformed unc path */
> +
> + do {
> + pos++;
> + } while (*pos && !is_dir_sep(*pos));
> +
> + offset = pos - path;
> + }
> +
> + return offset + is_dir_sep(path[offset]);
> +}
> diff --git a/compat/mingw.h b/compat/mingw.h
> index e033e72..3eaf822 100644
> --- a/compat/mingw.h
> +++ b/compat/mingw.h
> @@ -339,6 +339,8 @@ static inline char *mingw_find_last_dir_sep(const char *path)
> return ret;
> }
> #define find_last_dir_sep mingw_find_last_dir_sep
> +int mingw_offset_1st_component(const char *path);
> +#define offset_1st_component mingw_offset_1st_component
> #define PATH_SEP ';'
> #define PRIuMAX "I64u"
> #define PRId64 "I64d"
> diff --git a/git-compat-util.h b/git-compat-util.h
> index d493a8c..ec41cfb 100644
> --- a/git-compat-util.h
> +++ b/git-compat-util.h
> @@ -270,6 +270,10 @@ extern char *gitbasename(char *);
> #define has_dos_drive_prefix(path) 0
> #endif
>
> +#ifndef offset_1st_component
> +#define offset_1st_component(path) (is_dir_sep((path)[0]))
> +#endif
> +
> #ifndef is_dir_sep
> #define is_dir_sep(c) ((c) == '/')
> #endif
> diff --git a/path.c b/path.c
> index f9c5062..bc804a3 100644
> --- a/path.c
> +++ b/path.c
> @@ -823,10 +823,3 @@ int daemon_avoid_alias(const char *p)
> }
> }
> }
> -
> -int offset_1st_component(const char *path)
> -{
> - if (has_dos_drive_prefix(path))
> - return 2 + is_dir_sep(path[2]);
> - return is_dir_sep(path[0]);
> -}
> --
> 1.9.2.msysgit.0.490.ga07b726
>
> --
--
--
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.
You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en
---
You received this message because you are subscribed to the Google Groups "msysGit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Windows: Allow using UNC path for git repository
2014-05-20 18:57 ` Junio C Hamano
@ 2014-05-20 19:21 ` Stepan Kasal
2014-05-20 19:33 ` Junio C Hamano
0 siblings, 1 reply; 4+ messages in thread
From: Stepan Kasal @ 2014-05-20 19:21 UTC (permalink / raw)
To: Junio C Hamano
Cc: GIT Mailing-list, Erik Faye-Lund, msysGit, Cezary Zawadka,
Eric Sunshine
Hello,
On Tue, May 20, 2014 at 11:57:56AM -0700, Junio C Hamano wrote:
> It would be nice if somebody in the S-o-b chain can double-check
> that the "combined" version is sane. [...]
"Combined" was an unfortunate word. There was a pair of successive
commits in msysgit all the time. I just decided to submit them
squashed together. I haven't changed the code, just created a new
commit message.
That said, reviewing the function is always useful, of course.
Stepan
--
--
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.
You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en
---
You received this message because you are subscribed to the Google Groups "msysGit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Windows: Allow using UNC path for git repository
2014-05-20 19:21 ` Stepan Kasal
@ 2014-05-20 19:33 ` Junio C Hamano
0 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2014-05-20 19:33 UTC (permalink / raw)
To: Stepan Kasal
Cc: GIT Mailing-list, Erik Faye-Lund, msysGit, Cezary Zawadka,
Eric Sunshine
Stepan Kasal <kasal@ucw.cz> writes:
> Hello,
>
> On Tue, May 20, 2014 at 11:57:56AM -0700, Junio C Hamano wrote:
>> It would be nice if somebody in the S-o-b chain can double-check
>> that the "combined" version is sane. [...]
>
> "Combined" was an unfortunate word. There was a pair of successive
> commits in msysgit all the time. I just decided to submit them
> squashed together. I haven't changed the code, just created a new
> commit message.
>
> That said, reviewing the function is always useful, of course.
I did mis-read your message. As the patch shows the current state
that exists in msysgit that people are happy about, the function has
already been reviewed by stakeholders, and I would be happy to apply
it.
Thanks.
--
--
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.
You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en
---
You received this message because you are subscribed to the Google Groups "msysGit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-05-20 19:33 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-19 13:23 [PATCH] Windows: Allow using UNC path for git repository Stepan Kasal
2014-05-20 18:57 ` Junio C Hamano
2014-05-20 19:21 ` Stepan Kasal
2014-05-20 19:33 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).