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
fe9bfec4
Commit
fe9bfec4
authored
Jul 11, 2022
by
yuangli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tag: refactor tag name validity checks
parent
7560ac4d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
5 deletions
+15
-5
src/tag.c
+15
-5
No files found.
src/tag.c
View file @
fe9bfec4
...
...
@@ -244,6 +244,15 @@ on_error:
return
-
1
;
}
static
bool
tag_name_follows_pattern
(
const
char
*
tag_name
)
{
/*
* Discourage tag name starting with dash,
* https://github.com/git/git/commit/4f0accd638b8d2
*/
return
tag_name
[
0
]
!=
'-'
;
}
static
int
git_tag_create__internal
(
git_oid
*
oid
,
git_repository
*
repo
,
...
...
@@ -269,6 +278,11 @@ static int git_tag_create__internal(
return
-
1
;
}
if
(
!
tag_name_follows_pattern
(
tag_name
))
{
git_error_set
(
GIT_ERROR_TAG
,
"'%s' is not a valid tag name"
,
tag_name
);
return
-
1
;
}
error
=
retrieve_tag_reference_oid
(
oid
,
&
ref_name
,
repo
,
tag_name
);
if
(
error
<
0
&&
error
!=
GIT_ENOTFOUND
)
goto
cleanup
;
...
...
@@ -540,11 +554,7 @@ int git_tag_name_is_valid(int *valid, const char *name)
GIT_ASSERT
(
valid
);
/*
* Discourage tag name starting with dash,
* https://github.com/git/git/commit/4f0accd638b8d2
*/
if
(
!
name
||
name
[
0
]
==
'-'
)
if
(
!
name
||
!
tag_name_follows_pattern
(
name
))
goto
done
;
if
((
error
=
git_buf_puts
(
&
ref_name
,
GIT_REFS_TAGS_DIR
))
<
0
||
...
...
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