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
d8ad64d3
Commit
d8ad64d3
authored
Apr 02, 2011
by
Vicent Marti
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'parse-tag-buffer' of
https://github.com/carlosmn/libgit2
into development
parents
ccfce5f3
7b4a16e2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
1 deletions
+60
-1
include/git2/tag.h
+14
-0
src/tag.c
+46
-1
No files found.
include/git2/tag.h
View file @
d8ad64d3
...
...
@@ -188,6 +188,20 @@ GIT_EXTERN(int) git_tag_create_o(
const
git_signature
*
tagger
,
const
char
*
message
);
/**
* Create a new tag in the repository from a buffer
*
* @param oid Pointer where to store the OID of the newly created tag
*
* @param repo Repository where to store the tag
*
* @param buffer Raw tag data
*/
GIT_EXTERN
(
int
)
git_tag_create_frombuffer
(
git_oid
*
oid
,
git_repository
*
repo
,
const
char
*
buffer
);
/** @} */
GIT_END_DECL
#endif
src/tag.c
View file @
d8ad64d3
...
...
@@ -142,7 +142,7 @@ static int parse_tag_buffer(git_tag *tag, char *buffer, const char *buffer_end)
tag
->
tagger
=
git__malloc
(
sizeof
(
git_signature
));
if
((
error
=
git_signature__parse
(
tag
->
tagger
,
&
buffer
,
buffer_end
,
"tagger "
))
!=
0
)
return
error
;
goto
cleanup
;
text_len
=
buffer_end
-
++
buffer
;
...
...
@@ -151,6 +151,14 @@ static int parse_tag_buffer(git_tag *tag, char *buffer, const char *buffer_end)
tag
->
message
[
text_len
]
=
'\0'
;
return
GIT_SUCCESS
;
cleanup:
if
(
tag
->
tag_name
)
free
(
tag
->
tag_name
);
if
(
tag
->
tagger
)
git_signature_free
(
tag
->
tagger
);
return
error
;
}
int
git_tag_create_o
(
...
...
@@ -233,6 +241,43 @@ int git_tag_create(
return
error
;
}
int
git_tag_create_frombuffer
(
git_oid
*
oid
,
git_repository
*
repo
,
const
char
*
buffer
)
{
git_tag
tag
;
int
error
;
char
*
buf
;
git_object
*
obj
;
assert
(
oid
&&
buffer
);
memset
(
&
tag
,
0
,
sizeof
(
tag
));
buf
=
strdup
(
buffer
);
if
(
buf
==
NULL
)
return
GIT_ENOMEM
;
if
((
error
=
parse_tag_buffer
(
&
tag
,
buf
,
buf
+
strlen
(
buf
)))
<
0
)
goto
exit_freebuf
;
error
=
git_object_lookup
(
&
obj
,
repo
,
&
tag
.
target
,
tag
.
type
);
if
(
error
<
0
)
goto
exit_freetag
;
error
=
git_tag_create_o
(
oid
,
repo
,
tag
.
tag_name
,
obj
,
tag
.
tagger
,
tag
.
message
);
git_object_close
(
obj
);
exit_freetag:
git_signature_free
(
tag
.
tagger
);
free
(
tag
.
tag_name
);
free
(
tag
.
message
);
exit_freebuf:
free
(
buf
);
return
error
;
}
int
git_tag__parse
(
git_tag
*
tag
,
git_odb_object
*
obj
)
{
...
...
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