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
d9023dbe
Commit
d9023dbe
authored
Nov 20, 2012
by
Russell Belfer
Committed by
Ben Straub
Nov 27, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API updates for tag.h
parent
9cd42358
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
73 additions
and
70 deletions
+73
-70
include/git2/object.h
+3
-3
include/git2/tag.h
+56
-53
src/refs.c
+1
-1
src/tag.c
+12
-12
tests-clar/object/tag/write.c
+1
-1
No files found.
include/git2/object.h
View file @
d9023dbe
...
@@ -183,9 +183,9 @@ GIT_EXTERN(size_t) git_object__size(git_otype type);
...
@@ -183,9 +183,9 @@ GIT_EXTERN(size_t) git_object__size(git_otype type);
* @return 0 or an error code
* @return 0 or an error code
*/
*/
GIT_EXTERN
(
int
)
git_object_peel
(
GIT_EXTERN
(
int
)
git_object_peel
(
git_object
**
peeled
,
git_object
**
peeled
,
const
git_object
*
object
,
const
git_object
*
object
,
git_otype
target_type
);
git_otype
target_type
);
/** @} */
/** @} */
GIT_END_DECL
GIT_END_DECL
...
...
include/git2/tag.h
View file @
d9023dbe
...
@@ -25,14 +25,16 @@ GIT_BEGIN_DECL
...
@@ -25,14 +25,16 @@ GIT_BEGIN_DECL
/**
/**
* Lookup a tag object from the repository.
* Lookup a tag object from the repository.
*
*
* @param
tag
pointer to the looked up tag
* @param
out
pointer to the looked up tag
* @param repo the repo to use when locating the tag.
* @param repo the repo to use when locating the tag.
* @param id identity of the tag to locate.
* @param id identity of the tag to locate.
* @return 0 or an error code
* @return 0 or an error code
*/
*/
GIT_INLINE
(
int
)
git_tag_lookup
(
git_tag
**
tag
,
git_repository
*
repo
,
const
git_oid
*
id
)
GIT_INLINE
(
int
)
git_tag_lookup
(
git_tag
**
out
,
git_repository
*
repo
,
const
git_oid
*
id
)
{
{
return
git_object_lookup
((
git_object
**
)
tag
,
repo
,
id
,
(
git_otype
)
GIT_OBJ_TAG
);
return
git_object_lookup
(
(
git_object
**
)
out
,
repo
,
id
,
(
git_otype
)
GIT_OBJ_TAG
);
}
}
/**
/**
...
@@ -41,32 +43,33 @@ GIT_INLINE(int) git_tag_lookup(git_tag **tag, git_repository *repo, const git_oi
...
@@ -41,32 +43,33 @@ GIT_INLINE(int) git_tag_lookup(git_tag **tag, git_repository *repo, const git_oi
*
*
* @see git_object_lookup_prefix
* @see git_object_lookup_prefix
*
*
* @param
tag
pointer to the looked up tag
* @param
out
pointer to the looked up tag
* @param repo the repo to use when locating the tag.
* @param repo the repo to use when locating the tag.
* @param id identity of the tag to locate.
* @param id identity of the tag to locate.
* @param len the length of the short identifier
* @param len the length of the short identifier
* @return 0 or an error code
* @return 0 or an error code
*/
*/
GIT_INLINE
(
int
)
git_tag_lookup_prefix
(
git_tag
**
tag
,
git_repository
*
repo
,
const
git_oid
*
id
,
size_t
len
)
GIT_INLINE
(
int
)
git_tag_lookup_prefix
(
git_tag
**
out
,
git_repository
*
repo
,
const
git_oid
*
id
,
size_t
len
)
{
{
return
git_object_lookup_prefix
((
git_object
**
)
tag
,
repo
,
id
,
len
,
(
git_otype
)
GIT_OBJ_TAG
);
return
git_object_lookup_prefix
(
(
git_object
**
)
out
,
repo
,
id
,
len
,
(
git_otype
)
GIT_OBJ_TAG
);
}
}
/**
/**
* Close an open tag
* Close an open tag
*
*
*
This is a wrapper around git_object_free()
*
You can no longer use the git_tag pointer after this call.
*
*
* IMPORTANT:
* IMPORTANT: You MUST call this method when you are through with a tag to
* It *is* necessary to call this method when you stop
* release memory. Failure to do so will cause a memory leak.
* using a tag. Failure to do so will cause a memory leak.
*
*
* @param tag the tag to close
* @param tag the tag to close
*/
*/
GIT_INLINE
(
void
)
git_tag_free
(
git_tag
*
tag
)
GIT_INLINE
(
void
)
git_tag_free
(
git_tag
*
tag
)
{
{
git_object_free
((
git_object
*
)
tag
);
git_object_free
((
git_object
*
)
tag
);
}
}
...
@@ -76,7 +79,7 @@ GIT_INLINE(void) git_tag_free(git_tag *tag)
...
@@ -76,7 +79,7 @@ GIT_INLINE(void) git_tag_free(git_tag *tag)
* @param tag a previously loaded tag.
* @param tag a previously loaded tag.
* @return object identity for the tag.
* @return object identity for the tag.
*/
*/
GIT_EXTERN
(
const
git_oid
*
)
git_tag_id
(
git_tag
*
tag
);
GIT_EXTERN
(
const
git_oid
*
)
git_tag_id
(
const
git_tag
*
tag
);
/**
/**
* Get the tagged object of a tag
* Get the tagged object of a tag
...
@@ -84,11 +87,11 @@ GIT_EXTERN(const git_oid *) git_tag_id(git_tag *tag);
...
@@ -84,11 +87,11 @@ GIT_EXTERN(const git_oid *) git_tag_id(git_tag *tag);
* This method performs a repository lookup for the
* This method performs a repository lookup for the
* given object and returns it
* given object and returns it
*
*
* @param target pointer where to store the target
* @param target
_out
pointer where to store the target
* @param tag a previously loaded tag.
* @param tag a previously loaded tag.
* @return 0 or an error code
* @return 0 or an error code
*/
*/
GIT_EXTERN
(
int
)
git_tag_target
(
git_object
**
target
,
git_tag
*
tag
);
GIT_EXTERN
(
int
)
git_tag_target
(
git_object
**
target
_out
,
const
git_tag
*
tag
);
/**
/**
* Get the OID of the tagged object of a tag
* Get the OID of the tagged object of a tag
...
@@ -96,7 +99,7 @@ GIT_EXTERN(int) git_tag_target(git_object **target, git_tag *tag);
...
@@ -96,7 +99,7 @@ GIT_EXTERN(int) git_tag_target(git_object **target, git_tag *tag);
* @param tag a previously loaded tag.
* @param tag a previously loaded tag.
* @return pointer to the OID
* @return pointer to the OID
*/
*/
GIT_EXTERN
(
const
git_oid
*
)
git_tag_target_
oid
(
git_tag
*
tag
);
GIT_EXTERN
(
const
git_oid
*
)
git_tag_target_
id
(
const
git_tag
*
tag
);
/**
/**
* Get the type of a tag's tagged object
* Get the type of a tag's tagged object
...
@@ -104,7 +107,7 @@ GIT_EXTERN(const git_oid *) git_tag_target_oid(git_tag *tag);
...
@@ -104,7 +107,7 @@ GIT_EXTERN(const git_oid *) git_tag_target_oid(git_tag *tag);
* @param tag a previously loaded tag.
* @param tag a previously loaded tag.
* @return type of the tagged object
* @return type of the tagged object
*/
*/
GIT_EXTERN
(
git_otype
)
git_tag_target_type
(
git_tag
*
tag
);
GIT_EXTERN
(
git_otype
)
git_tag_target_type
(
const
git_tag
*
tag
);
/**
/**
* Get the name of a tag
* Get the name of a tag
...
@@ -112,7 +115,7 @@ GIT_EXTERN(git_otype) git_tag_target_type(git_tag *tag);
...
@@ -112,7 +115,7 @@ GIT_EXTERN(git_otype) git_tag_target_type(git_tag *tag);
* @param tag a previously loaded tag.
* @param tag a previously loaded tag.
* @return name of the tag
* @return name of the tag
*/
*/
GIT_EXTERN
(
const
char
*
)
git_tag_name
(
git_tag
*
tag
);
GIT_EXTERN
(
const
char
*
)
git_tag_name
(
const
git_tag
*
tag
);
/**
/**
* Get the tagger (author) of a tag
* Get the tagger (author) of a tag
...
@@ -120,7 +123,7 @@ GIT_EXTERN(const char *) git_tag_name(git_tag *tag);
...
@@ -120,7 +123,7 @@ GIT_EXTERN(const char *) git_tag_name(git_tag *tag);
* @param tag a previously loaded tag.
* @param tag a previously loaded tag.
* @return reference to the tag's author
* @return reference to the tag's author
*/
*/
GIT_EXTERN
(
const
git_signature
*
)
git_tag_tagger
(
git_tag
*
tag
);
GIT_EXTERN
(
const
git_signature
*
)
git_tag_tagger
(
const
git_tag
*
tag
);
/**
/**
* Get the message of a tag
* Get the message of a tag
...
@@ -128,7 +131,7 @@ GIT_EXTERN(const git_signature *) git_tag_tagger(git_tag *tag);
...
@@ -128,7 +131,7 @@ GIT_EXTERN(const git_signature *) git_tag_tagger(git_tag *tag);
* @param tag a previously loaded tag.
* @param tag a previously loaded tag.
* @return message of the tag
* @return message of the tag
*/
*/
GIT_EXTERN
(
const
char
*
)
git_tag_message
(
git_tag
*
tag
);
GIT_EXTERN
(
const
char
*
)
git_tag_message
(
const
git_tag
*
tag
);
/**
/**
...
@@ -167,13 +170,13 @@ GIT_EXTERN(const char *) git_tag_message(git_tag *tag);
...
@@ -167,13 +170,13 @@ GIT_EXTERN(const char *) git_tag_message(git_tag *tag);
* is written in the /refs/tags folder, pointing to it
* is written in the /refs/tags folder, pointing to it
*/
*/
GIT_EXTERN
(
int
)
git_tag_create
(
GIT_EXTERN
(
int
)
git_tag_create
(
git_oid
*
oid
,
git_oid
*
oid
,
git_repository
*
repo
,
git_repository
*
repo
,
const
char
*
tag_name
,
const
char
*
tag_name
,
const
git_object
*
target
,
const
git_object
*
target
,
const
git_signature
*
tagger
,
const
git_signature
*
tagger
,
const
char
*
message
,
const
char
*
message
,
int
force
);
int
force
);
/**
/**
* Create a new tag in the repository from a buffer
* Create a new tag in the repository from a buffer
...
@@ -185,10 +188,10 @@ GIT_EXTERN(int) git_tag_create(
...
@@ -185,10 +188,10 @@ GIT_EXTERN(int) git_tag_create(
* @return 0 on success; error code otherwise
* @return 0 on success; error code otherwise
*/
*/
GIT_EXTERN
(
int
)
git_tag_create_frombuffer
(
GIT_EXTERN
(
int
)
git_tag_create_frombuffer
(
git_oid
*
oid
,
git_oid
*
oid
,
git_repository
*
repo
,
git_repository
*
repo
,
const
char
*
buffer
,
const
char
*
buffer
,
int
force
);
int
force
);
/**
/**
* Create a new lightweight tag pointing at a target object
* Create a new lightweight tag pointing at a target object
...
@@ -218,11 +221,11 @@ GIT_EXTERN(int) git_tag_create_frombuffer(
...
@@ -218,11 +221,11 @@ GIT_EXTERN(int) git_tag_create_frombuffer(
* pointing to the provided target object
* pointing to the provided target object
*/
*/
GIT_EXTERN
(
int
)
git_tag_create_lightweight
(
GIT_EXTERN
(
int
)
git_tag_create_lightweight
(
git_oid
*
oid
,
git_oid
*
oid
,
git_repository
*
repo
,
git_repository
*
repo
,
const
char
*
tag_name
,
const
char
*
tag_name
,
const
git_object
*
target
,
const
git_object
*
target
,
int
force
);
int
force
);
/**
/**
* Delete an existing tag reference.
* Delete an existing tag reference.
...
@@ -235,8 +238,8 @@ GIT_EXTERN(int) git_tag_create_lightweight(
...
@@ -235,8 +238,8 @@ GIT_EXTERN(int) git_tag_create_lightweight(
* @return 0 or an error code
* @return 0 or an error code
*/
*/
GIT_EXTERN
(
int
)
git_tag_delete
(
GIT_EXTERN
(
int
)
git_tag_delete
(
git_repository
*
repo
,
git_repository
*
repo
,
const
char
*
tag_name
);
const
char
*
tag_name
);
/**
/**
* Fill a list with all the tags in the Repository
* Fill a list with all the tags in the Repository
...
@@ -252,8 +255,8 @@ GIT_EXTERN(int) git_tag_delete(
...
@@ -252,8 +255,8 @@ GIT_EXTERN(int) git_tag_delete(
* @return 0 or an error code
* @return 0 or an error code
*/
*/
GIT_EXTERN
(
int
)
git_tag_list
(
GIT_EXTERN
(
int
)
git_tag_list
(
git_strarray
*
tag_names
,
git_strarray
*
tag_names
,
git_repository
*
repo
);
git_repository
*
repo
);
/**
/**
* Fill a list with all the tags in the Repository
* Fill a list with all the tags in the Repository
...
@@ -274,39 +277,39 @@ GIT_EXTERN(int) git_tag_list(
...
@@ -274,39 +277,39 @@ GIT_EXTERN(int) git_tag_list(
* @return 0 or an error code
* @return 0 or an error code
*/
*/
GIT_EXTERN
(
int
)
git_tag_list_match
(
GIT_EXTERN
(
int
)
git_tag_list_match
(
git_strarray
*
tag_names
,
git_strarray
*
tag_names
,
const
char
*
pattern
,
const
char
*
pattern
,
git_repository
*
repo
);
git_repository
*
repo
);
typedef
int
(
*
git_tag_foreach_cb
)(
const
char
*
name
,
git_oid
*
oid
,
void
*
data
);
typedef
int
(
*
git_tag_foreach_cb
)(
const
char
*
name
,
git_oid
*
oid
,
void
*
payload
);
/**
/**
* Call callback `cb' for each tag in the repository
* Call callback `cb' for each tag in the repository
*
*
* @param repo Repository
* @param repo Repository
* @param c
b
Callback function
* @param c
allback
Callback function
* @param
cb_data
Pointer to callback data (optional)
* @param
payload
Pointer to callback data (optional)
*/
*/
GIT_EXTERN
(
int
)
git_tag_foreach
(
GIT_EXTERN
(
int
)
git_tag_foreach
(
git_repository
*
repo
,
git_repository
*
repo
,
git_tag_foreach_cb
cb
,
git_tag_foreach_cb
callback
,
void
*
cb_data
);
void
*
payload
);
/**
/**
* Recursively peel a tag until a non tag git_object
* Recursively peel a tag until a non tag git_object is found
* is met
*
*
* The retrieved `tag_target` object is owned by the repository
* The retrieved `tag_target` object is owned by the repository
* and should be closed with the `git_object_free` method.
* and should be closed with the `git_object_free` method.
*
*
* @param tag_target Pointer to the peeled git_object
* @param tag_target
_out
Pointer to the peeled git_object
* @param tag The tag to be processed
* @param tag The tag to be processed
* @return 0 or an error code
* @return 0 or an error code
*/
*/
GIT_EXTERN
(
int
)
git_tag_peel
(
GIT_EXTERN
(
int
)
git_tag_peel
(
git_object
**
tag_targe
t
,
git_object
**
tag_target_ou
t
,
git_tag
*
tag
);
const
git_tag
*
tag
);
/** @} */
/** @} */
GIT_END_DECL
GIT_END_DECL
...
...
src/refs.c
View file @
d9023dbe
...
@@ -647,7 +647,7 @@ static int packed_find_peel(git_repository *repo, struct packref *ref)
...
@@ -647,7 +647,7 @@ static int packed_find_peel(git_repository *repo, struct packref *ref)
/*
/*
* Find the object pointed at by this tag
* Find the object pointed at by this tag
*/
*/
git_oid_cpy
(
&
ref
->
peel
,
git_tag_target_
o
id
(
tag
));
git_oid_cpy
(
&
ref
->
peel
,
git_tag_target_id
(
tag
));
ref
->
flags
|=
GIT_PACKREF_HAS_PEEL
;
ref
->
flags
|=
GIT_PACKREF_HAS_PEEL
;
/*
/*
...
...
src/tag.c
View file @
d9023dbe
...
@@ -22,41 +22,41 @@ void git_tag__free(git_tag *tag)
...
@@ -22,41 +22,41 @@ void git_tag__free(git_tag *tag)
git__free
(
tag
);
git__free
(
tag
);
}
}
const
git_oid
*
git_tag_id
(
git_tag
*
c
)
const
git_oid
*
git_tag_id
(
const
git_tag
*
c
)
{
{
return
git_object_id
((
git_object
*
)
c
);
return
git_object_id
((
const
git_object
*
)
c
);
}
}
int
git_tag_target
(
git_object
**
target
,
git_tag
*
t
)
int
git_tag_target
(
git_object
**
target
,
const
git_tag
*
t
)
{
{
assert
(
t
);
assert
(
t
);
return
git_object_lookup
(
target
,
t
->
object
.
repo
,
&
t
->
target
,
t
->
type
);
return
git_object_lookup
(
target
,
t
->
object
.
repo
,
&
t
->
target
,
t
->
type
);
}
}
const
git_oid
*
git_tag_target_
oid
(
git_tag
*
t
)
const
git_oid
*
git_tag_target_
id
(
const
git_tag
*
t
)
{
{
assert
(
t
);
assert
(
t
);
return
&
t
->
target
;
return
&
t
->
target
;
}
}
git_otype
git_tag_target_type
(
git_tag
*
t
)
git_otype
git_tag_target_type
(
const
git_tag
*
t
)
{
{
assert
(
t
);
assert
(
t
);
return
t
->
type
;
return
t
->
type
;
}
}
const
char
*
git_tag_name
(
git_tag
*
t
)
const
char
*
git_tag_name
(
const
git_tag
*
t
)
{
{
assert
(
t
);
assert
(
t
);
return
t
->
tag_name
;
return
t
->
tag_name
;
}
}
const
git_signature
*
git_tag_tagger
(
git_tag
*
t
)
const
git_signature
*
git_tag_tagger
(
const
git_tag
*
t
)
{
{
return
t
->
tagger
;
return
t
->
tagger
;
}
}
const
char
*
git_tag_message
(
git_tag
*
t
)
const
char
*
git_tag_message
(
const
git_tag
*
t
)
{
{
assert
(
t
);
assert
(
t
);
return
t
->
message
;
return
t
->
message
;
...
@@ -425,8 +425,8 @@ int git_tag_foreach(git_repository *repo, git_tag_foreach_cb cb, void *cb_data)
...
@@ -425,8 +425,8 @@ int git_tag_foreach(git_repository *repo, git_tag_foreach_cb cb, void *cb_data)
data
.
cb_data
=
cb_data
;
data
.
cb_data
=
cb_data
;
data
.
repo
=
repo
;
data
.
repo
=
repo
;
return
git_reference_foreach
(
repo
,
GIT_REF_OID
|
GIT_REF_PACKED
,
return
git_reference_foreach
(
&
tags_cb
,
&
data
);
repo
,
GIT_REF_OID
|
GIT_REF_PACKED
,
&
tags_cb
,
&
data
);
}
}
typedef
struct
{
typedef
struct
{
...
@@ -477,7 +477,7 @@ int git_tag_list(git_strarray *tag_names, git_repository *repo)
...
@@ -477,7 +477,7 @@ int git_tag_list(git_strarray *tag_names, git_repository *repo)
return
git_tag_list_match
(
tag_names
,
""
,
repo
);
return
git_tag_list_match
(
tag_names
,
""
,
repo
);
}
}
int
git_tag_peel
(
git_object
**
tag_target
,
git_tag
*
tag
)
int
git_tag_peel
(
git_object
**
tag_target
,
const
git_tag
*
tag
)
{
{
return
git_object_peel
(
tag_target
,
(
git_object
*
)
tag
,
GIT_OBJ_ANY
);
return
git_object_peel
(
tag_target
,
(
const
git_object
*
)
tag
,
GIT_OBJ_ANY
);
}
}
tests-clar/object/tag/write.c
View file @
d9023dbe
...
@@ -45,7 +45,7 @@ void test_object_tag_write__basic(void)
...
@@ -45,7 +45,7 @@ void test_object_tag_write__basic(void)
git_signature_free
(
tagger
);
git_signature_free
(
tagger
);
cl_git_pass
(
git_tag_lookup
(
&
tag
,
g_repo
,
&
tag_id
));
cl_git_pass
(
git_tag_lookup
(
&
tag
,
g_repo
,
&
tag_id
));
cl_assert
(
git_oid_cmp
(
git_tag_target_
o
id
(
tag
),
&
target_id
)
==
0
);
cl_assert
(
git_oid_cmp
(
git_tag_target_id
(
tag
),
&
target_id
)
==
0
);
/* Check attributes were set correctly */
/* Check attributes were set correctly */
tagger1
=
git_tag_tagger
(
tag
);
tagger1
=
git_tag_tagger
(
tag
);
...
...
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