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
0532e7bb
Commit
0532e7bb
authored
Oct 19, 2012
by
nulltoken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
branch: allow deletion of branch when HEAD's missing
parent
8dd0bef9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
5 deletions
+10
-5
src/branch.c
+7
-1
tests-clar/refs/branches/delete.c
+3
-4
No files found.
src/branch.c
View file @
0532e7bb
...
@@ -265,13 +265,19 @@ int git_branch_is_head(
...
@@ -265,13 +265,19 @@ int git_branch_is_head(
{
{
git_reference
*
head
;
git_reference
*
head
;
bool
is_same
=
false
;
bool
is_same
=
false
;
int
error
;
assert
(
branch
);
assert
(
branch
);
if
(
!
git_reference_is_branch
(
branch
))
if
(
!
git_reference_is_branch
(
branch
))
return
false
;
return
false
;
if
(
git_repository_head
(
&
head
,
git_reference_owner
(
branch
))
<
0
)
error
=
git_repository_head
(
&
head
,
git_reference_owner
(
branch
));
if
(
error
==
GIT_ENOTFOUND
)
return
false
;
if
(
error
<
0
)
return
-
1
;
return
-
1
;
is_same
=
strcmp
(
is_same
=
strcmp
(
...
...
tests-clar/refs/branches/delete.c
View file @
0532e7bb
...
@@ -38,17 +38,16 @@ void test_refs_branches_delete__can_not_delete_a_branch_pointed_at_by_HEAD(void)
...
@@ -38,17 +38,16 @@ void test_refs_branches_delete__can_not_delete_a_branch_pointed_at_by_HEAD(void)
git_reference_free
(
branch
);
git_reference_free
(
branch
);
}
}
void
test_refs_branches_delete__can_
not_delete_a_branch
_if_HEAD_is_missing
(
void
)
void
test_refs_branches_delete__can_
delete_a_branch_even
_if_HEAD_is_missing
(
void
)
{
{
git_reference
*
head
;
git_reference
*
head
;
git_reference
*
branch
=
NULL
;
git_reference
*
branch
;
cl_git_pass
(
git_reference_lookup
(
&
head
,
repo
,
GIT_HEAD_FILE
));
cl_git_pass
(
git_reference_lookup
(
&
head
,
repo
,
GIT_HEAD_FILE
));
git_reference_delete
(
head
);
git_reference_delete
(
head
);
cl_git_pass
(
git_branch_lookup
(
&
branch
,
repo
,
"br2"
,
GIT_BRANCH_LOCAL
));
cl_git_pass
(
git_branch_lookup
(
&
branch
,
repo
,
"br2"
,
GIT_BRANCH_LOCAL
));
cl_git_fail
(
git_branch_delete
(
branch
));
cl_git_pass
(
git_branch_delete
(
branch
));
git_reference_free
(
branch
);
}
}
void
test_refs_branches_delete__can_delete_a_branch_pointed_at_by_detached_HEAD
(
void
)
void
test_refs_branches_delete__can_delete_a_branch_pointed_at_by_detached_HEAD
(
void
)
...
...
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