summaryrefslogtreecommitdiff
path: root/src/path.c
diff options
context:
space:
mode:
authorVicent Martí <vicent@github.com>2012-12-26 16:08:10 -0800
committerVicent Martí <vicent@github.com>2012-12-26 16:08:10 -0800
commit83261a449f76147c1ebb3ebe592821f7d69bb6f6 (patch)
treee892158408191911921778bda4938f1989b97a4a /src/path.c
parent7382551ff75fd7890752d3c64de85dc99115449e (diff)
parent50a762a563fe8116e2707ce1fcb75391d41dca23 (diff)
downloadlibgit2-83261a449f76147c1ebb3ebe592821f7d69bb6f6.tar.gz
Merge pull request #1173 from nulltoken/bug/discover
Teach UNC paths to git_path_dirname_r()
Diffstat (limited to 'src/path.c')
-rw-r--r--src/path.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/path.c b/src/path.c
index 569101c40..dd6bb70ad 100644
--- a/src/path.c
+++ b/src/path.c
@@ -19,6 +19,22 @@
#define LOOKS_LIKE_DRIVE_PREFIX(S) (git__isalpha((S)[0]) && (S)[1] == ':')
+static bool looks_like_network_computer_name(const char *path, int pos)
+{
+ if (pos < 3)
+ return false;
+
+ if (path[0] != '/' || path[1] != '/')
+ return false;
+
+ while (pos-- > 2) {
+ if (path[pos] == '/')
+ return false;
+ }
+
+ return true;
+}
+
/*
* Based on the Android implementation, BSD licensed.
* Check http://android.git.kernel.org/
@@ -111,6 +127,15 @@ int git_path_dirname_r(git_buf *buffer, const char *path)
len = 3;
goto Exit;
}
+
+ /* Similarly checks if we're dealing with a network computer name
+ '//computername/.git' will return '//computername/' */
+
+ if (looks_like_network_computer_name(path, len)) {
+ len++;
+ goto Exit;
+ }
+
#endif
Exit: