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
9e680bcc
Commit
9e680bcc
authored
Mar 30, 2011
by
nulltoken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add git_tag_delete()
parent
a50c1458
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
2 deletions
+57
-2
include/git2/tag.h
+14
-0
src/tag.c
+29
-2
tests/t08-tag.c
+14
-0
No files found.
include/git2/tag.h
View file @
9e680bcc
...
...
@@ -247,6 +247,20 @@ GIT_EXTERN(int) git_tag_create_o_f(
const
git_signature
*
tagger
,
const
char
*
message
);
/**
* Delete an existing tag reference.
*
* @param repo Repository where lives the tag
*
* @param tag_name Name of the tag to be deleted;
* this name is validated for consistency.
*
* @return 0 on success; error code otherwise.
*/
GIT_EXTERN
(
int
)
git_tag_delete
(
git_repository
*
repo
,
const
char
*
tag_name
);
/** @} */
GIT_END_DECL
#endif
src/tag.c
View file @
9e680bcc
...
...
@@ -153,6 +153,21 @@ static int parse_tag_buffer(git_tag *tag, char *buffer, const char *buffer_end)
return
GIT_SUCCESS
;
}
static
int
retreive_tag_reference
(
git_reference
**
tag_reference_out
,
char
*
ref_name_out
,
git_repository
*
repo
,
const
char
*
tag_name
)
{
git_reference
*
tag_ref
;
int
error
;
git__joinpath
(
ref_name_out
,
GIT_REFS_TAGS_DIR
,
tag_name
);
error
=
git_reference_lookup
(
&
tag_ref
,
repo
,
ref_name_out
);
if
(
error
<
GIT_SUCCESS
)
return
error
;
*
tag_reference_out
=
tag_ref
;;
return
GIT_SUCCESS
;
}
static
int
tag_create
(
git_oid
*
oid
,
git_repository
*
repo
,
...
...
@@ -177,8 +192,7 @@ static int tag_create(
/** Ensure the tag name doesn't conflict with an already existing
reference unless overwriting has explictly been requested **/
git__joinpath
(
ref_name
,
GIT_REFS_TAGS_DIR
,
tag_name
);
error
=
git_reference_lookup
(
&
new_ref
,
repo
,
ref_name
);
error
=
retreive_tag_reference
(
&
new_ref
,
ref_name
,
repo
,
tag_name
);
switch
(
error
)
{
case
GIT_SUCCESS
:
...
...
@@ -305,6 +319,19 @@ int git_tag_create_f(
tagger
,
message
,
1
);
}
int
git_tag_delete
(
git_repository
*
repo
,
const
char
*
tag_name
)
{
int
error
;
git_reference
*
tag_ref
;
char
ref_name
[
MAX_GITDIR_TREE_STRUCTURE_PATH_LENGTH
];
error
=
retreive_tag_reference
(
&
tag_ref
,
ref_name
,
repo
,
tag_name
);
if
(
error
<
GIT_SUCCESS
)
return
error
;
return
git_reference_delete
(
tag_ref
);
}
int
git_tag__parse
(
git_tag
*
tag
,
git_odb_object
*
obj
)
{
assert
(
tag
);
...
...
tests/t08-tag.c
View file @
9e680bcc
...
...
@@ -225,6 +225,20 @@ BEGIN_TEST(write3, "Replace an already existing tag")
END_TEST
BEGIN_TEST
(
write4
,
"Delete an already existing tag"
)
git_repository
*
repo
;
git_reference
*
ref_tag
;
must_pass
(
open_temp_repo
(
&
repo
,
REPOSITORY_FOLDER
));
must_pass
(
git_tag_delete
(
repo
,
"very-simple"
));
must_fail
(
git_reference_lookup
(
&
ref_tag
,
repo
,
"refs/tags/very-simple"
));
close_temp_repo
(
repo
);
END_TEST
BEGIN_SUITE
(
tag
)
ADD_TEST
(
read0
);
ADD_TEST
(
write0
);
...
...
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