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
b0885675
Commit
b0885675
authored
Sep 13, 2015
by
Carlos Martín Nieto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3425 from ethomson/diriter_root
Handle `git_path_diriter` instances at the drive root on Windows
parents
ceb01c09
9d905541
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
2 deletions
+39
-2
src/path.c
+10
-2
tests/core/dirent.c
+29
-0
No files found.
src/path.c
View file @
b0885675
...
...
@@ -1166,7 +1166,11 @@ static int diriter_update_paths(git_path_diriter *diriter)
diriter
->
path
[
path_len
-
1
]
=
L'\0'
;
git_buf_truncate
(
&
diriter
->
path_utf8
,
diriter
->
parent_utf8_len
);
git_buf_putc
(
&
diriter
->
path_utf8
,
'/'
);
if
(
diriter
->
parent_utf8_len
>
0
&&
diriter
->
path_utf8
.
ptr
[
diriter
->
parent_utf8_len
-
1
]
!=
'/'
)
git_buf_putc
(
&
diriter
->
path_utf8
,
'/'
);
git_buf_put_w
(
&
diriter
->
path_utf8
,
diriter
->
current
.
cFileName
,
filename_len
);
if
(
git_buf_oom
(
&
diriter
->
path_utf8
))
...
...
@@ -1315,7 +1319,11 @@ int git_path_diriter_next(git_path_diriter *diriter)
#endif
git_buf_truncate
(
&
diriter
->
path
,
diriter
->
parent_len
);
git_buf_putc
(
&
diriter
->
path
,
'/'
);
if
(
diriter
->
parent_len
>
0
&&
diriter
->
path
.
ptr
[
diriter
->
parent_len
-
1
]
!=
'/'
)
git_buf_putc
(
&
diriter
->
path
,
'/'
);
git_buf_put
(
&
diriter
->
path
,
filename
,
filename_len
);
if
(
git_buf_oom
(
&
diriter
->
path
))
...
...
tests/core/dirent.c
View file @
b0885675
...
...
@@ -275,3 +275,32 @@ void test_core_dirent__diriter_with_fullname(void)
check_counts
(
&
sub
);
}
void
test_core_dirent__diriter_at_directory_root
(
void
)
{
git_path_diriter
diriter
=
GIT_PATH_DIRITER_INIT
;
const
char
*
sandbox_path
,
*
path
;
char
*
root_path
;
size_t
path_len
;
int
root_offset
,
error
;
sandbox_path
=
clar_sandbox_path
();
cl_assert
((
root_offset
=
git_path_root
(
sandbox_path
))
>=
0
);
cl_assert
(
root_path
=
git__calloc
(
1
,
root_offset
+
2
));
strncpy
(
root_path
,
sandbox_path
,
root_offset
+
1
);
cl_git_pass
(
git_path_diriter_init
(
&
diriter
,
root_path
,
0
));
while
((
error
=
git_path_diriter_next
(
&
diriter
))
==
0
)
{
cl_git_pass
(
git_path_diriter_fullpath
(
&
path
,
&
path_len
,
&
diriter
));
cl_assert
(
path_len
>
(
size_t
)(
root_offset
+
1
));
cl_assert
(
path
[
root_offset
+
1
]
!=
'/'
);
}
cl_assert_equal_i
(
error
,
GIT_ITEROVER
);
git_path_diriter_free
(
&
diriter
);
git__free
(
root_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