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
a58854a0
Commit
a58854a0
authored
Jul 13, 2015
by
Carlos Martín Nieto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
submodule, path: extract slash conversion
Extract the backslash-to-slash conversion into a helper function.
parent
f00f005b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
7 deletions
+24
-7
src/path.c
+16
-0
src/path.h
+5
-0
src/submodule.c
+3
-7
No files found.
src/path.c
View file @
a58854a0
...
...
@@ -1671,3 +1671,19 @@ bool git_path_isvalid(
return
verify_component
(
repo
,
start
,
(
c
-
start
),
flags
);
}
int
git_path_normalize_slashes
(
git_buf
*
out
,
const
char
*
path
)
{
int
error
;
char
*
p
;
if
((
error
=
git_buf_puts
(
out
,
path
))
<
0
)
return
error
;
for
(
p
=
out
->
ptr
;
*
p
;
p
++
)
{
if
(
*
p
==
'\\'
)
*
p
=
'/'
;
}
return
0
;
}
src/path.h
View file @
a58854a0
...
...
@@ -591,4 +591,9 @@ extern bool git_path_isvalid(
const
char
*
path
,
unsigned
int
flags
);
/**
* Convert any backslashes into slashes
*/
int
git_path_normalize_slashes
(
git_buf
*
out
,
const
char
*
path
);
#endif
src/submodule.c
View file @
a58854a0
...
...
@@ -787,19 +787,15 @@ int git_submodule_resolve_url(git_buf *out, git_repository *repo, const char *ur
git_buf_sanitize
(
out
);
/* We do this in all platforms in case someone on Windows created the .gitmodules */
if
(
strchr
(
url
,
'\\'
))
{
char
*
p
;
if
((
error
=
git_buf_puts
(
&
normalized
,
url
))
<
0
)
if
((
error
=
git_path_normalize_slashes
(
&
normalized
,
url
))
<
0
)
return
error
;
for
(
p
=
normalized
.
ptr
;
*
p
;
p
++
)
{
if
(
*
p
==
'\\'
)
*
p
=
'/'
;
}
url
=
normalized
.
ptr
;
}
if
(
git_path_is_relative
(
url
))
{
if
(
!
(
error
=
get_url_base
(
out
,
repo
)))
error
=
git_path_apply_relative
(
out
,
url
);
...
...
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