Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
83261a44
Commit
83261a44
authored
Dec 26, 2012
by
Vicent Martí
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1173 from nulltoken/bug/discover
Teach UNC paths to git_path_dirname_r()
parents
7382551f
50a762a5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
0 deletions
+34
-0
src/path.c
+25
-0
tests-clar/core/path.c
+9
-0
No files found.
src/path.c
View file @
83261a44
...
@@ -19,6 +19,22 @@
...
@@ -19,6 +19,22 @@
#define LOOKS_LIKE_DRIVE_PREFIX(S) (git__isalpha((S)[0]) && (S)[1] == ':')
#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.
* Based on the Android implementation, BSD licensed.
* Check http://android.git.kernel.org/
* Check http://android.git.kernel.org/
...
@@ -111,6 +127,15 @@ int git_path_dirname_r(git_buf *buffer, const char *path)
...
@@ -111,6 +127,15 @@ int git_path_dirname_r(git_buf *buffer, const char *path)
len
=
3
;
len
=
3
;
goto
Exit
;
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
#endif
Exit:
Exit:
...
...
tests-clar/core/path.c
View file @
83261a44
...
@@ -87,6 +87,15 @@ void test_core_path__00_dirname(void)
...
@@ -87,6 +87,15 @@ void test_core_path__00_dirname(void)
check_dirname
(
".git/"
,
"."
);
check_dirname
(
".git/"
,
"."
);
check_dirname
(
REP16
(
"/abc"
),
REP15
(
"/abc"
));
check_dirname
(
REP16
(
"/abc"
),
REP15
(
"/abc"
));
#ifdef GIT_WIN32
check_dirname
(
"C:/path/"
,
"C:/"
);
check_dirname
(
"C:/path"
,
"C:/"
);
check_dirname
(
"//computername/path/"
,
"//computername/"
);
check_dirname
(
"//computername/path"
,
"//computername/"
);
check_dirname
(
"//computername/sub/path/"
,
"//computername/sub"
);
check_dirname
(
"//computername/sub/path"
,
"//computername/sub"
);
#endif
}
}
/* get the base name of a path */
/* get the base name of a path */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment