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
55a7117d
Commit
55a7117d
authored
Oct 11, 2020
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remote: use git_remote_name_is_valid
parent
023ebb9a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
10 deletions
+19
-10
src/remote.c
+4
-2
tests/network/remote/isvalidname.c
+15
-8
No files found.
src/remote.c
View file @
55a7117d
...
@@ -82,9 +82,11 @@ static int download_tags_value(git_remote *remote, git_config *cfg)
...
@@ -82,9 +82,11 @@ static int download_tags_value(git_remote *remote, git_config *cfg)
static
int
ensure_remote_name_is_valid
(
const
char
*
name
)
static
int
ensure_remote_name_is_valid
(
const
char
*
name
)
{
{
int
error
=
0
;
int
valid
,
error
;
error
=
git_remote_name_is_valid
(
&
valid
,
name
);
if
(
!
git_remote_is_valid_name
(
name
)
)
{
if
(
!
error
&&
!
valid
)
{
git_error_set
(
git_error_set
(
GIT_ERROR_CONFIG
,
GIT_ERROR_CONFIG
,
"'%s' is not a valid remote name."
,
name
?
name
:
"(null)"
);
"'%s' is not a valid remote name."
,
name
?
name
:
"(null)"
);
...
...
tests/network/remote/isvalidname.c
View file @
55a7117d
#include "clar_libgit2.h"
#include "clar_libgit2.h"
static
int
is_valid_name
(
const
char
*
name
)
{
int
valid
=
0
;
cl_git_pass
(
git_remote_name_is_valid
(
&
valid
,
name
));
return
valid
;
}
void
test_network_remote_isvalidname__can_detect_invalid_formats
(
void
)
void
test_network_remote_isvalidname__can_detect_invalid_formats
(
void
)
{
{
cl_assert_equal_i
(
false
,
git_remote_
is_valid_name
(
"/"
));
cl_assert_equal_i
(
false
,
is_valid_name
(
"/"
));
cl_assert_equal_i
(
false
,
git_remote_
is_valid_name
(
"//"
));
cl_assert_equal_i
(
false
,
is_valid_name
(
"//"
));
cl_assert_equal_i
(
false
,
git_remote_
is_valid_name
(
".lock"
));
cl_assert_equal_i
(
false
,
is_valid_name
(
".lock"
));
cl_assert_equal_i
(
false
,
git_remote_
is_valid_name
(
"a.lock"
));
cl_assert_equal_i
(
false
,
is_valid_name
(
"a.lock"
));
cl_assert_equal_i
(
false
,
git_remote_
is_valid_name
(
"/no/leading/slash"
));
cl_assert_equal_i
(
false
,
is_valid_name
(
"/no/leading/slash"
));
cl_assert_equal_i
(
false
,
git_remote_
is_valid_name
(
"no/trailing/slash/"
));
cl_assert_equal_i
(
false
,
is_valid_name
(
"no/trailing/slash/"
));
}
}
void
test_network_remote_isvalidname__wont_hopefully_choke_on_valid_formats
(
void
)
void
test_network_remote_isvalidname__wont_hopefully_choke_on_valid_formats
(
void
)
{
{
cl_assert_equal_i
(
true
,
git_remote_
is_valid_name
(
"webmatrix"
));
cl_assert_equal_i
(
true
,
is_valid_name
(
"webmatrix"
));
cl_assert_equal_i
(
true
,
git_remote_
is_valid_name
(
"yishaigalatzer/rules"
));
cl_assert_equal_i
(
true
,
is_valid_name
(
"yishaigalatzer/rules"
));
}
}
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