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
50ad7cc2
Commit
50ad7cc2
authored
Feb 02, 2014
by
Arthur Schreiber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add `git_reference_is_note`.
parent
40e10630
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
0 deletions
+36
-0
include/git2/refs.h
+10
-0
src/refs.c
+11
-0
tests/refs/read.c
+15
-0
No files found.
include/git2/refs.h
View file @
50ad7cc2
...
...
@@ -510,6 +510,16 @@ GIT_EXTERN(int) git_reference_is_remote(git_reference *ref);
*/
GIT_EXTERN
(
int
)
git_reference_is_tag
(
git_reference
*
ref
);
/**
* Check if a reference is a note
*
* @param ref A git reference
*
* @return 1 when the reference lives in the refs/notes
* namespace; 0 otherwise.
*/
GIT_EXTERN
(
int
)
git_reference_is_note
(
git_reference
*
ref
);
typedef
enum
{
GIT_REF_FORMAT_NORMAL
=
0u
,
...
...
src/refs.c
View file @
50ad7cc2
...
...
@@ -1113,6 +1113,17 @@ int git_reference_is_tag(git_reference *ref)
return
git_reference__is_tag
(
ref
->
name
);
}
int
git_reference__is_note
(
const
char
*
ref_name
)
{
return
git__prefixcmp
(
ref_name
,
GIT_REFS_NOTES_DIR
)
==
0
;
}
int
git_reference_is_note
(
git_reference
*
ref
)
{
assert
(
ref
);
return
git_reference__is_note
(
ref
->
name
);
}
static
int
peel_error
(
int
error
,
git_reference
*
ref
,
const
char
*
msg
)
{
giterr_set
(
...
...
tests/refs/read.c
View file @
50ad7cc2
...
...
@@ -271,6 +271,21 @@ void test_refs_read__can_determine_if_a_reference_is_a_tag(void)
assert_is_tag
(
"refs/remotes/test/master"
,
false
);
}
static
void
assert_is_note
(
const
char
*
name
,
bool
expected_noteness
)
{
git_reference
*
reference
;
cl_git_pass
(
git_reference_lookup
(
&
reference
,
g_repo
,
name
));
cl_assert_equal_i
(
expected_noteness
,
git_reference_is_note
(
reference
));
git_reference_free
(
reference
);
}
void
test_refs_read__can_determine_if_a_reference_is_a_note
(
void
)
{
assert_is_note
(
"refs/notes/fanout"
,
true
);
assert_is_note
(
"refs/heads/packed"
,
false
);
assert_is_note
(
"refs/remotes/test/master"
,
false
);
}
void
test_refs_read__invalid_name_returns_EINVALIDSPEC
(
void
)
{
git_reference
*
reference
;
...
...
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