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
7d24070d
Commit
7d24070d
authored
Apr 05, 2020
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
branch: use GIT_ASSERT
parent
abb7a7e4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
10 deletions
+22
-10
src/branch.c
+22
-10
No files found.
src/branch.c
View file @
7d24070d
...
...
@@ -67,8 +67,10 @@ static int create_branch(
int
error
=
-
1
;
int
bare
=
git_repository_is_bare
(
repository
);
assert
(
branch_name
&&
commit
&&
ref_out
);
assert
(
git_object_owner
((
const
git_object
*
)
commit
)
==
repository
);
GIT_ASSERT_ARG
(
branch_name
);
GIT_ASSERT_ARG
(
commit
);
GIT_ASSERT_ARG
(
ref_out
);
GIT_ASSERT_ARG
(
git_commit_owner
(
commit
)
==
repository
);
if
(
!
git__strcmp
(
branch_name
,
"HEAD"
))
{
git_error_set
(
GIT_ERROR_REFERENCE
,
"'HEAD' is not a valid branch name"
);
...
...
@@ -161,6 +163,8 @@ out:
int
git_branch_is_checked_out
(
const
git_reference
*
branch
)
{
GIT_ASSERT_ARG
(
branch
);
if
(
!
git_reference_is_branch
(
branch
))
return
0
;
return
git_repository_foreach_worktree
(
git_reference_owner
(
branch
),
...
...
@@ -173,7 +177,7 @@ int git_branch_delete(git_reference *branch)
git_buf
config_section
=
GIT_BUF_INIT
;
int
error
=
-
1
;
assert
(
branch
);
GIT_ASSERT_ARG
(
branch
);
if
(
!
git_reference_is_branch
(
branch
)
&&
!
git_reference_is_remote
(
branch
))
{
git_error_set
(
GIT_ERROR_INVALID
,
"reference '%s' is not a valid branch."
,
...
...
@@ -288,7 +292,8 @@ int git_branch_move(
log_message
=
GIT_BUF_INIT
;
int
error
;
assert
(
branch
&&
new_branch_name
);
GIT_ASSERT_ARG
(
branch
);
GIT_ASSERT_ARG
(
new_branch_name
);
if
(
!
git_reference_is_branch
(
branch
))
return
not_a_local_branch
(
git_reference_name
(
branch
));
...
...
@@ -333,7 +338,10 @@ int git_branch_lookup(
git_branch_t
branch_type
)
{
int
error
=
-
1
;
assert
(
ref_out
&&
repo
&&
branch_name
);
GIT_ASSERT_ARG
(
ref_out
);
GIT_ASSERT_ARG
(
repo
);
GIT_ASSERT_ARG
(
branch_name
);
switch
(
branch_type
)
{
case
GIT_BRANCH_LOCAL
:
...
...
@@ -346,7 +354,7 @@ int git_branch_lookup(
error
=
retrieve_branch_reference
(
ref_out
,
repo
,
branch_name
,
true
);
break
;
default:
assert
(
false
);
GIT_ASSERT
(
false
);
}
return
error
;
}
...
...
@@ -357,7 +365,8 @@ int git_branch_name(
{
const
char
*
branch_name
;
assert
(
out
&&
ref
);
GIT_ASSERT_ARG
(
out
);
GIT_ASSERT_ARG
(
ref
);
branch_name
=
ref
->
name
;
...
...
@@ -405,7 +414,8 @@ int git_branch_upstream_name(
const
git_refspec
*
refspec
;
git_config
*
config
;
assert
(
out
&&
refname
);
GIT_ASSERT_ARG
(
out
);
GIT_ASSERT_ARG
(
refname
);
git_buf_sanitize
(
out
);
...
...
@@ -491,7 +501,9 @@ int git_branch_remote_name(git_buf *buf, git_repository *repo, const char *refna
int
error
=
0
;
char
*
remote_name
=
NULL
;
assert
(
buf
&&
repo
&&
refname
);
GIT_ASSERT_ARG
(
buf
);
GIT_ASSERT_ARG
(
repo
);
GIT_ASSERT_ARG
(
refname
);
git_buf_sanitize
(
buf
);
...
...
@@ -702,7 +714,7 @@ int git_branch_is_head(
bool
is_same
=
false
;
int
error
;
assert
(
branch
);
GIT_ASSERT_ARG
(
branch
);
if
(
!
git_reference_is_branch
(
branch
))
return
false
;
...
...
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