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
80a6e86b
Commit
80a6e86b
authored
Oct 11, 2012
by
Ben Straub
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #974 from nulltoken/EEXISTS
Enforce returning of EEXISTS when trying to overwrite a reference
parents
26ddcfa4
b73200c1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
21 additions
and
11 deletions
+21
-11
src/branch.c
+4
-5
src/refs.c
+2
-2
tests-clar/object/tag/write.c
+2
-2
tests-clar/refs/branches/create.c
+1
-1
tests-clar/refs/branches/move.c
+1
-1
tests-clar/refs/rename.c
+11
-0
No files found.
src/branch.c
View file @
80a6e86b
...
...
@@ -77,12 +77,11 @@ int git_branch_create(
if
(
git_buf_joinpath
(
&
canonical_branch_name
,
GIT_REFS_HEADS_DIR
,
branch_name
)
<
0
)
goto
cleanup
;
if
(
git_reference_create_oid
(
&
branch
,
repository
,
git_buf_cstr
(
&
canonical_branch_name
),
git_object_id
(
commit
),
force
)
<
0
)
goto
cleanup
;
error
=
git_reference_create_oid
(
&
branch
,
repository
,
git_buf_cstr
(
&
canonical_branch_name
),
git_object_id
(
commit
),
force
);
*
ref_out
=
branch
;
error
=
0
;
if
(
!
error
)
*
ref_out
=
branch
;
cleanup:
git_object_free
(
commit
);
...
...
src/refs.c
View file @
80a6e86b
...
...
@@ -1357,8 +1357,8 @@ int git_reference_rename(git_reference *ref, const char *new_name, int force)
normalization_flags
)
<
0
)
return
-
1
;
if
(
reference_can_write
(
ref
->
owner
,
normalized
,
ref
->
name
,
force
)
<
0
)
return
-
1
;
if
(
(
result
=
reference_can_write
(
ref
->
owner
,
normalized
,
ref
->
name
,
force
)
)
<
0
)
return
result
;
/* Initialize path now so we won't get an allocation failure once
* we actually start removing things. */
...
...
tests-clar/object/tag/write.c
View file @
80a6e86b
...
...
@@ -77,7 +77,7 @@ void test_object_tag_write__overwrite(void)
/* create signature */
cl_git_pass
(
git_signature_new
(
&
tagger
,
tagger_name
,
tagger_email
,
123456789
,
60
));
cl_
git_fail
(
git_tag_create
(
cl_
assert_equal_i
(
GIT_EEXISTS
,
git_tag_create
(
&
tag_id
,
/* out id */
g_repo
,
"e90810b"
,
...
...
@@ -166,7 +166,7 @@ void test_object_tag_write__lightweight_over_existing(void)
git_oid_fromstr
(
&
target_id
,
tagged_commit
);
cl_git_pass
(
git_object_lookup
(
&
target
,
g_repo
,
&
target_id
,
GIT_OBJ_COMMIT
));
cl_
git_fail
(
git_tag_create_lightweight
(
cl_
assert_equal_i
(
GIT_EEXISTS
,
git_tag_create_lightweight
(
&
object_id
,
g_repo
,
"e90810b"
,
...
...
tests-clar/refs/branches/create.c
View file @
80a6e86b
...
...
@@ -50,7 +50,7 @@ void test_refs_branches_create__can_not_create_a_branch_if_its_name_collide_with
{
retrieve_known_commit
(
&
target
,
repo
);
cl_
git_fail
(
git_branch_create
(
&
branch
,
repo
,
"br2"
,
target
,
0
));
cl_
assert_equal_i
(
GIT_EEXISTS
,
git_branch_create
(
&
branch
,
repo
,
"br2"
,
target
,
0
));
}
void
test_refs_branches_create__can_force_create_over_an_existing_branch
(
void
)
...
...
tests-clar/refs/branches/move.c
View file @
80a6e86b
...
...
@@ -45,7 +45,7 @@ void test_refs_branches_move__can_move_a_local_branch_to_a_partially_colliding_n
void
test_refs_branches_move__can_not_move_a_branch_if_its_destination_name_collide_with_an_existing_one
(
void
)
{
cl_
git_fail
(
git_branch_move
(
ref
,
"master"
,
0
));
cl_
assert_equal_i
(
GIT_EEXISTS
,
git_branch_move
(
ref
,
"master"
,
0
));
}
void
test_refs_branches_move__can_not_move_a_non_branch
(
void
)
...
...
tests-clar/refs/rename.c
View file @
80a6e86b
...
...
@@ -337,3 +337,14 @@ void test_refs_rename__move_up(void)
git_reference_free
(
ref
);
git_reference_free
(
looked_up_ref
);
}
void
test_refs_rename__propagate_eexists
(
void
)
{
git_reference
*
ref
;
cl_git_pass
(
git_reference_lookup
(
&
ref
,
g_repo
,
packed_head_name
));
cl_assert_equal_i
(
GIT_EEXISTS
,
git_reference_rename
(
ref
,
packed_test_head_name
,
0
));
git_reference_free
(
ref
);
}
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