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
b31f50fd
Commit
b31f50fd
authored
Apr 01, 2021
by
Ian Hattendorf
Committed by
Edward Thomson
Jun 30, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Default to GIT_BRANCH_DEFAULT if init.defaultBranch is empty string
We already do this in repo_init_head
parent
8b16a4aa
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
2 deletions
+16
-2
src/repository.c
+3
-2
tests/repo/getters.c
+13
-0
No files found.
src/repository.c
View file @
b31f50fd
...
...
@@ -2365,10 +2365,11 @@ int git_repository_initialbranch(git_buf *out, git_repository *repo)
if
((
error
=
git_repository_config__weakptr
(
&
config
,
repo
))
<
0
)
return
error
;
if
((
error
=
git_config_get_entry
(
&
entry
,
config
,
"init.defaultbranch"
))
==
0
)
{
if
((
error
=
git_config_get_entry
(
&
entry
,
config
,
"init.defaultbranch"
))
==
0
&&
*
entry
->
value
)
{
branch
=
entry
->
value
;
}
else
if
(
error
==
GIT_ENOTFOUND
)
{
else
if
(
!
error
||
error
==
GIT_ENOTFOUND
)
{
branch
=
GIT_BRANCH_DEFAULT
;
}
else
{
...
...
tests/repo/getters.c
View file @
b31f50fd
#include "clar_libgit2.h"
#include "repo/repo_helpers.h"
void
test_repo_getters__is_empty_correctly_deals_with_pristine_looking_repos
(
void
)
{
...
...
@@ -23,6 +24,18 @@ void test_repo_getters__is_empty_can_detect_used_repositories(void)
git_repository_free
(
repo
);
}
void
test_repo_getters__is_empty_can_detect_repositories_with_defaultbranch_config_empty
(
void
)
{
git_repository
*
repo
;
create_tmp_global_config
(
"tmp_global_path"
,
"init.defaultBranch"
,
""
);
cl_git_pass
(
git_repository_open
(
&
repo
,
cl_fixture
(
"testrepo.git"
)));
cl_assert_equal_i
(
false
,
git_repository_is_empty
(
repo
));
git_repository_free
(
repo
);
}
void
test_repo_getters__retrieving_the_odb_honors_the_refcount
(
void
)
{
git_odb
*
odb
;
...
...
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