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
341a7136
Commit
341a7136
authored
May 13, 2012
by
nulltoken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
branch: make git_branch_delete() return GIT_ENOTFOUND when the branch doesn't exist
parent
b72969e0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
1 deletions
+16
-1
src/branch.c
+1
-1
tests-clar/refs/branches/delete.c
+15
-0
No files found.
src/branch.c
View file @
341a7136
...
...
@@ -114,7 +114,7 @@ int git_branch_delete(git_repository *repo, const char *branch_name, git_branch_
assert
((
branch_type
==
GIT_BRANCH_LOCAL
)
||
(
branch_type
==
GIT_BRANCH_REMOTE
));
if
((
error
=
retrieve_branch_reference
(
&
branch
,
repo
,
branch_name
,
branch_type
==
GIT_BRANCH_REMOTE
))
<
0
)
goto
on_
error
;
return
error
;
if
(
git_reference_lookup
(
&
head
,
repo
,
GIT_HEAD_FILE
)
<
0
)
{
giterr_set
(
GITERR_REFERENCE
,
"Cannot locate HEAD."
);
...
...
tests-clar/refs/branches/delete.c
View file @
341a7136
...
...
@@ -74,3 +74,18 @@ void test_refs_branches_delete__can_delete_a_remote_branch(void)
{
cl_git_pass
(
git_branch_delete
(
repo
,
"nulltoken/master"
,
GIT_BRANCH_REMOTE
));
}
static
void
assert_non_exisitng_branch_removal
(
const
char
*
branch_name
,
git_branch_type
branch_type
)
{
int
error
;
error
=
git_branch_delete
(
repo
,
branch_name
,
branch_type
);
cl_git_fail
(
error
);
cl_assert_equal_i
(
GIT_ENOTFOUND
,
error
);
}
void
test_refs_branches_delete__deleting_a_non_existing_branch_returns_ENOTFOUND
(
void
)
{
assert_non_exisitng_branch_removal
(
"i-do-not-locally-exist"
,
GIT_BRANCH_LOCAL
);
assert_non_exisitng_branch_removal
(
"neither/remotely"
,
GIT_BRANCH_REMOTE
);
}
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