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
7376ad99
Commit
7376ad99
authored
Jun 29, 2011
by
Vicent Marti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refs: Remove duplicate rename method
`git_reference_rename` now takes a `force` flag
parent
5f25149e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
140 additions
and
164 deletions
+140
-164
include/git2/refs.h
+1
-15
src/refs.c
+132
-142
tests/t10-refs.c
+7
-7
No files found.
include/git2/refs.h
View file @
7376ad99
...
@@ -195,21 +195,7 @@ GIT_EXTERN(int) git_reference_set_oid(git_reference *ref, const git_oid *id);
...
@@ -195,21 +195,7 @@ GIT_EXTERN(int) git_reference_set_oid(git_reference *ref, const git_oid *id);
* and on disk.
* and on disk.
*
*
*/
*/
GIT_EXTERN
(
int
)
git_reference_rename
(
git_reference
*
ref
,
const
char
*
new_name
);
GIT_EXTERN
(
int
)
git_reference_rename
(
git_reference
*
ref
,
const
char
*
new_name
,
int
force
);
/**
* Rename an existing reference, overwriting an existing one with the
* same name, if it exists.
*
* This method works for both direct and symbolic references.
* The new name will be checked for validity and may be
* modified into a normalized form.
*
* The refernece will be immediately renamed in-memory
* and on disk.
*
*/
GIT_EXTERN
(
int
)
git_reference_rename_f
(
git_reference
*
ref
,
const
char
*
new_name
);
/**
/**
* Delete an existing reference
* Delete an existing reference
...
...
src/refs.c
View file @
7376ad99
This diff is collapsed.
Click to expand it.
tests/t10-refs.c
View file @
7376ad99
...
@@ -494,7 +494,7 @@ BEGIN_TEST(rename0, "rename a loose reference")
...
@@ -494,7 +494,7 @@ BEGIN_TEST(rename0, "rename a loose reference")
must_be_true
((
looked_up_ref
->
type
&
GIT_REF_PACKED
)
==
0
);
must_be_true
((
looked_up_ref
->
type
&
GIT_REF_PACKED
)
==
0
);
/* Now that the reference is renamed... */
/* Now that the reference is renamed... */
must_pass
(
git_reference_rename
(
looked_up_ref
,
new_name
));
must_pass
(
git_reference_rename
(
looked_up_ref
,
new_name
,
0
));
must_be_true
(
!
strcmp
(
looked_up_ref
->
name
,
new_name
));
must_be_true
(
!
strcmp
(
looked_up_ref
->
name
,
new_name
));
/* ...It can't be looked-up with the old name... */
/* ...It can't be looked-up with the old name... */
...
@@ -534,7 +534,7 @@ BEGIN_TEST(rename1, "rename a packed reference (should make it loose)")
...
@@ -534,7 +534,7 @@ BEGIN_TEST(rename1, "rename a packed reference (should make it loose)")
must_be_true
((
looked_up_ref
->
type
&
GIT_REF_PACKED
)
!=
0
);
must_be_true
((
looked_up_ref
->
type
&
GIT_REF_PACKED
)
!=
0
);
/* Now that the reference is renamed... */
/* Now that the reference is renamed... */
must_pass
(
git_reference_rename
(
looked_up_ref
,
brand_new_name
));
must_pass
(
git_reference_rename
(
looked_up_ref
,
brand_new_name
,
0
));
must_be_true
(
!
strcmp
(
looked_up_ref
->
name
,
brand_new_name
));
must_be_true
(
!
strcmp
(
looked_up_ref
->
name
,
brand_new_name
));
/* ...It can't be looked-up with the old name... */
/* ...It can't be looked-up with the old name... */
...
@@ -580,7 +580,7 @@ BEGIN_TEST(rename2, "renaming a packed reference does not pack another reference
...
@@ -580,7 +580,7 @@ BEGIN_TEST(rename2, "renaming a packed reference does not pack another reference
must_be_true
((
looked_up_ref
->
type
&
GIT_REF_PACKED
)
!=
0
);
must_be_true
((
looked_up_ref
->
type
&
GIT_REF_PACKED
)
!=
0
);
/* Now that the reference is renamed... */
/* Now that the reference is renamed... */
must_pass
(
git_reference_rename
(
looked_up_ref
,
brand_new_name
));
must_pass
(
git_reference_rename
(
looked_up_ref
,
brand_new_name
,
0
));
/* Lookup the other reference */
/* Lookup the other reference */
must_pass
(
git_reference_lookup
(
&
another_looked_up_ref
,
repo
,
packed_test_head_name
));
must_pass
(
git_reference_lookup
(
&
another_looked_up_ref
,
repo
,
packed_test_head_name
));
...
@@ -604,7 +604,7 @@ BEGIN_TEST(rename3, "can not rename a reference with the name of an existing ref
...
@@ -604,7 +604,7 @@ BEGIN_TEST(rename3, "can not rename a reference with the name of an existing ref
must_pass
(
git_reference_lookup
(
&
looked_up_ref
,
repo
,
packed_head_name
));
must_pass
(
git_reference_lookup
(
&
looked_up_ref
,
repo
,
packed_head_name
));
/* Can not be renamed to the name of another existing reference. */
/* Can not be renamed to the name of another existing reference. */
must_fail
(
git_reference_rename
(
looked_up_ref
,
packed_test_head_name
));
must_fail
(
git_reference_rename
(
looked_up_ref
,
packed_test_head_name
,
0
));
/* Failure to rename it hasn't corrupted its state */
/* Failure to rename it hasn't corrupted its state */
must_pass
(
git_reference_lookup
(
&
looked_up_ref
,
repo
,
packed_head_name
));
must_pass
(
git_reference_lookup
(
&
looked_up_ref
,
repo
,
packed_head_name
));
...
@@ -623,10 +623,10 @@ BEGIN_TEST(rename4, "can not rename a reference with an invalid name")
...
@@ -623,10 +623,10 @@ BEGIN_TEST(rename4, "can not rename a reference with an invalid name")
must_pass
(
git_reference_lookup
(
&
looked_up_ref
,
repo
,
packed_test_head_name
));
must_pass
(
git_reference_lookup
(
&
looked_up_ref
,
repo
,
packed_test_head_name
));
/* Can not be renamed with an invalid name. */
/* Can not be renamed with an invalid name. */
must_fail
(
git_reference_rename
(
looked_up_ref
,
"Hello! I'm a very invalid name."
));
must_fail
(
git_reference_rename
(
looked_up_ref
,
"Hello! I'm a very invalid name."
,
0
));
/* Can not be renamed outside of the refs hierarchy. */
/* Can not be renamed outside of the refs hierarchy. */
must_fail
(
git_reference_rename
(
looked_up_ref
,
"i-will-sudo-you"
));
must_fail
(
git_reference_rename
(
looked_up_ref
,
"i-will-sudo-you"
,
0
));
/* Failure to rename it hasn't corrupted its state */
/* Failure to rename it hasn't corrupted its state */
must_pass
(
git_reference_lookup
(
&
looked_up_ref
,
repo
,
packed_test_head_name
));
must_pass
(
git_reference_lookup
(
&
looked_up_ref
,
repo
,
packed_test_head_name
));
...
@@ -645,7 +645,7 @@ BEGIN_TEST(rename5, "can force-rename a reference with the name of an existing r
...
@@ -645,7 +645,7 @@ BEGIN_TEST(rename5, "can force-rename a reference with the name of an existing r
must_pass
(
git_reference_lookup
(
&
looked_up_ref
,
repo
,
packed_head_name
));
must_pass
(
git_reference_lookup
(
&
looked_up_ref
,
repo
,
packed_head_name
));
/* Can be force-renamed to the name of another existing reference. */
/* Can be force-renamed to the name of another existing reference. */
must_pass
(
git_reference_rename
_f
(
looked_up_ref
,
packed_test_head_name
));
must_pass
(
git_reference_rename
(
looked_up_ref
,
packed_test_head_name
,
1
));
/* Check we actually renamed it */
/* Check we actually renamed it */
must_pass
(
git_reference_lookup
(
&
looked_up_ref
,
repo
,
packed_test_head_name
));
must_pass
(
git_reference_lookup
(
&
looked_up_ref
,
repo
,
packed_test_head_name
));
...
...
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