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
669db21b
Commit
669db21b
authored
Feb 28, 2011
by
nulltoken
Committed by
Vicent Marti
Mar 03, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Slightly changed the behavior of git__joinpath() and git__joinpath_n().
parent
52b2c209
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
3 deletions
+26
-3
src/util.c
+5
-1
tests/t00-core.c
+21
-2
No files found.
src/util.c
View file @
669db21b
...
@@ -206,6 +206,7 @@ void git__joinpath_n(char *buffer_out, int count, ...)
...
@@ -206,6 +206,7 @@ void git__joinpath_n(char *buffer_out, int count, ...)
{
{
va_list
ap
;
va_list
ap
;
int
i
;
int
i
;
char
*
buffer_start
=
buffer_out
;
va_start
(
ap
,
count
);
va_start
(
ap
,
count
);
for
(
i
=
0
;
i
<
count
;
++
i
)
{
for
(
i
=
0
;
i
<
count
;
++
i
)
{
...
@@ -213,9 +214,12 @@ void git__joinpath_n(char *buffer_out, int count, ...)
...
@@ -213,9 +214,12 @@ void git__joinpath_n(char *buffer_out, int count, ...)
int
len
;
int
len
;
path
=
va_arg
(
ap
,
const
char
*
);
path
=
va_arg
(
ap
,
const
char
*
);
if
(
i
>
0
&&
*
path
==
'/'
)
if
(
i
>
0
&&
*
path
==
'/'
&&
buffer_out
>
buffer_start
&&
buffer_out
[
-
1
]
==
'/'
)
path
++
;
path
++
;
if
(
!*
path
)
continue
;
len
=
strlen
(
path
);
len
=
strlen
(
path
);
memcpy
(
buffer_out
,
path
,
len
);
memcpy
(
buffer_out
,
path
,
len
);
buffer_out
=
buffer_out
+
len
;
buffer_out
=
buffer_out
+
len
;
...
...
tests/t00-core.c
View file @
669db21b
...
@@ -355,9 +355,11 @@ static int ensure_joinpath(const char *path_a, const char *path_b, const char *e
...
@@ -355,9 +355,11 @@ static int ensure_joinpath(const char *path_a, const char *path_b, const char *e
}
}
BEGIN_TEST
(
"path"
,
joinpath
)
BEGIN_TEST
(
"path"
,
joinpath
)
must_pass
(
ensure_joinpath
(
""
,
""
,
"/"
));
must_pass
(
ensure_joinpath
(
""
,
""
,
""
));
must_pass
(
ensure_joinpath
(
""
,
"a"
,
"/a"
));
must_pass
(
ensure_joinpath
(
""
,
"a"
,
"a"
));
must_pass
(
ensure_joinpath
(
""
,
"/a"
,
"/a"
));
must_pass
(
ensure_joinpath
(
"a"
,
""
,
"a/"
));
must_pass
(
ensure_joinpath
(
"a"
,
""
,
"a/"
));
must_pass
(
ensure_joinpath
(
"a"
,
"/"
,
"a/"
));
must_pass
(
ensure_joinpath
(
"a"
,
"b"
,
"a/b"
));
must_pass
(
ensure_joinpath
(
"a"
,
"b"
,
"a/b"
));
must_pass
(
ensure_joinpath
(
"/"
,
"a"
,
"/a"
));
must_pass
(
ensure_joinpath
(
"/"
,
"a"
,
"/a"
));
must_pass
(
ensure_joinpath
(
"/"
,
""
,
"/"
));
must_pass
(
ensure_joinpath
(
"/"
,
""
,
"/"
));
...
@@ -367,6 +369,22 @@ BEGIN_TEST("path", joinpath)
...
@@ -367,6 +369,22 @@ BEGIN_TEST("path", joinpath)
must_pass
(
ensure_joinpath
(
"/a/"
,
"/b/"
,
"/a/b/"
));
must_pass
(
ensure_joinpath
(
"/a/"
,
"/b/"
,
"/a/b/"
));
END_TEST
END_TEST
static
int
ensure_joinpath_n
(
const
char
*
path_a
,
const
char
*
path_b
,
const
char
*
path_c
,
const
char
*
path_d
,
const
char
*
expected_path
)
{
char
joined_path
[
GIT_PATH_MAX
];
git__joinpath_n
(
joined_path
,
4
,
path_a
,
path_b
,
path_c
,
path_d
);
return
strcmp
(
joined_path
,
expected_path
)
==
0
?
GIT_SUCCESS
:
GIT_ERROR
;
}
BEGIN_TEST
(
"path"
,
joinpath_n
)
must_pass
(
ensure_joinpath_n
(
""
,
""
,
""
,
""
,
""
));
must_pass
(
ensure_joinpath_n
(
""
,
"a"
,
""
,
""
,
"a/"
));
must_pass
(
ensure_joinpath_n
(
"a"
,
""
,
""
,
""
,
"a/"
));
must_pass
(
ensure_joinpath_n
(
""
,
""
,
""
,
"a"
,
"a"
));
must_pass
(
ensure_joinpath_n
(
"a"
,
"b"
,
""
,
"/c/d/"
,
"a/b/c/d/"
));
must_pass
(
ensure_joinpath_n
(
"a"
,
"b"
,
""
,
"/c/d"
,
"a/b/c/d"
));
END_TEST
typedef
struct
name_data
{
typedef
struct
name_data
{
int
count
;
/* return count */
int
count
;
/* return count */
char
*
name
;
/* filename */
char
*
name
;
/* filename */
...
@@ -627,6 +645,7 @@ git_testsuite *libgit2_suite_core(void)
...
@@ -627,6 +645,7 @@ git_testsuite *libgit2_suite_core(void)
ADD_TEST
(
suite
,
"path"
,
file_path_prettifying
);
ADD_TEST
(
suite
,
"path"
,
file_path_prettifying
);
ADD_TEST
(
suite
,
"path"
,
dir_path_prettifying
);
ADD_TEST
(
suite
,
"path"
,
dir_path_prettifying
);
ADD_TEST
(
suite
,
"path"
,
joinpath
);
ADD_TEST
(
suite
,
"path"
,
joinpath
);
ADD_TEST
(
suite
,
"path"
,
joinpath_n
);
ADD_TEST
(
suite
,
"dirent"
,
dot
);
ADD_TEST
(
suite
,
"dirent"
,
dot
);
ADD_TEST
(
suite
,
"dirent"
,
sub
);
ADD_TEST
(
suite
,
"dirent"
,
sub
);
...
...
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