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
392eced6
Commit
392eced6
authored
May 11, 2012
by
nulltoken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
branch: retrieve symbolic references when listing the branches
parent
88d6e044
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
2 deletions
+31
-2
src/branch.c
+1
-1
tests-clar/refs/branches/listall.c
+30
-1
No files found.
src/branch.c
View file @
392eced6
...
@@ -170,7 +170,7 @@ int git_branch_list(git_strarray *branch_names, git_repository *repo, unsigned i
...
@@ -170,7 +170,7 @@ int git_branch_list(git_strarray *branch_names, git_repository *repo, unsigned i
filter
.
branchlist
=
&
branchlist
;
filter
.
branchlist
=
&
branchlist
;
filter
.
branch_type
=
list_flags
;
filter
.
branch_type
=
list_flags
;
error
=
git_reference_foreach
(
repo
,
GIT_REF_
OID
|
GIT_REF_PACKED
,
&
branch_list_cb
,
(
void
*
)
&
filter
);
error
=
git_reference_foreach
(
repo
,
GIT_REF_
LISTALL
,
&
branch_list_cb
,
(
void
*
)
&
filter
);
if
(
error
<
0
)
{
if
(
error
<
0
)
{
git_vector_free
(
&
branchlist
);
git_vector_free
(
&
branchlist
);
return
-
1
;
return
-
1
;
...
...
tests-clar/refs/branches/listall.c
View file @
392eced6
...
@@ -30,7 +30,7 @@ static void assert_retrieval(unsigned int flags, unsigned int expected_count)
...
@@ -30,7 +30,7 @@ static void assert_retrieval(unsigned int flags, unsigned int expected_count)
{
{
cl_git_pass
(
git_branch_list
(
&
branch_list
,
repo
,
flags
));
cl_git_pass
(
git_branch_list
(
&
branch_list
,
repo
,
flags
));
cl_assert
(
branch_list
.
count
==
expected_
count
);
cl_assert
_equal_i
(
expected_count
,
branch_list
.
count
);
}
}
void
test_refs_branches_listall__retrieve_all_branches
(
void
)
void
test_refs_branches_listall__retrieve_all_branches
(
void
)
...
@@ -47,3 +47,32 @@ void test_refs_branches_listall__retrieve_local_branches(void)
...
@@ -47,3 +47,32 @@ void test_refs_branches_listall__retrieve_local_branches(void)
{
{
assert_retrieval
(
GIT_BRANCH_LOCAL
,
6
);
assert_retrieval
(
GIT_BRANCH_LOCAL
,
6
);
}
}
static
void
assert_branch_list_contains
(
git_strarray
*
branches
,
const
char
*
expected_branch_name
)
{
unsigned
int
i
;
for
(
i
=
0
;
i
<
branches
->
count
;
i
++
)
{
if
(
strcmp
(
expected_branch_name
,
branches
->
strings
[
i
])
==
0
)
return
;
}
cl_fail
(
"expected branch not found in list."
);
}
/*
* $ git branch -r
* nulltoken/HEAD -> nulltoken/master
* nulltoken/master
*/
void
test_refs_branches_listall__retrieve_remote_symbolic_HEAD_when_present
(
void
)
{
git_reference_free
(
fake_remote
);
cl_git_pass
(
git_reference_create_symbolic
(
&
fake_remote
,
repo
,
"refs/remotes/nulltoken/HEAD"
,
"refs/remotes/nulltoken/master"
,
0
));
cl_git_pass
(
git_branch_list
(
&
branch_list
,
repo
,
GIT_BRANCH_REMOTE
));
cl_assert_equal_i
(
2
,
branch_list
.
count
);
assert_branch_list_contains
(
&
branch_list
,
"refs/remotes/nulltoken/HEAD"
);
assert_branch_list_contains
(
&
branch_list
,
"refs/remotes/nulltoken/master"
);
}
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