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
59b1dbcd
Commit
59b1dbcd
authored
Feb 27, 2014
by
Linquize
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not allow git_branch_create() to force update branch
parent
40e10630
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
0 deletions
+13
-0
src/branch.c
+13
-0
No files found.
src/branch.c
View file @
59b1dbcd
...
@@ -58,6 +58,7 @@ int git_branch_create(
...
@@ -58,6 +58,7 @@ int git_branch_create(
const
git_signature
*
signature
,
const
git_signature
*
signature
,
const
char
*
log_message
)
const
char
*
log_message
)
{
{
int
is_head
=
0
;
git_reference
*
branch
=
NULL
;
git_reference
*
branch
=
NULL
;
git_buf
canonical_branch_name
=
GIT_BUF_INIT
,
git_buf
canonical_branch_name
=
GIT_BUF_INIT
,
log_message_buf
=
GIT_BUF_INIT
;
log_message_buf
=
GIT_BUF_INIT
;
...
@@ -65,7 +66,19 @@ int git_branch_create(
...
@@ -65,7 +66,19 @@ int git_branch_create(
assert
(
branch_name
&&
commit
&&
ref_out
);
assert
(
branch_name
&&
commit
&&
ref_out
);
assert
(
git_object_owner
((
const
git_object
*
)
commit
)
==
repository
);
assert
(
git_object_owner
((
const
git_object
*
)
commit
)
==
repository
);
if
(
git_branch_lookup
(
&
branch
,
repository
,
branch_name
,
GIT_BRANCH_LOCAL
)
==
0
)
{
if
((
is_head
=
git_branch_is_head
(
branch
))
<
0
)
{
error
=
is_head
;
goto
cleanup
;
}
}
if
(
is_head
&&
force
)
{
giterr_set
(
GITERR_REFERENCE
,
"Cannot force update branch '%s' as it is "
"the current HEAD of the repository."
,
git_reference_name
(
branch
));
goto
cleanup
;
}
if
(
git_buf_joinpath
(
&
canonical_branch_name
,
GIT_REFS_HEADS_DIR
,
branch_name
)
<
0
)
if
(
git_buf_joinpath
(
&
canonical_branch_name
,
GIT_REFS_HEADS_DIR
,
branch_name
)
<
0
)
goto
cleanup
;
goto
cleanup
;
...
...
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