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
805dc2a0
Commit
805dc2a0
authored
Sep 20, 2011
by
Vicent Martí
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #415 from schu/ref-rename-regression
refs: fix git_reference_rename()
parents
4e52d340
93fdbe00
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
4 deletions
+37
-4
src/refs.c
+7
-4
tests/t10-refs.c
+30
-0
No files found.
src/refs.c
View file @
805dc2a0
...
...
@@ -1287,8 +1287,13 @@ int git_reference_rename(git_reference *ref, const char *new_name, int force)
error
=
git_reference_delete
(
new_ref
);
}
if
(
error
<
GIT_SUCCESS
&&
error
!=
GIT_ENOTFOUND
)
goto
cleanup
;
if
(
error
<
GIT_SUCCESS
)
{
git_path_join
(
aux_path
,
ref
->
owner
->
path_repository
,
new_name
);
/* If we couldn't read the reference because it doesn't
* exist it's ok - otherwise return */
if
(
git_futils_isfile
(
aux_path
)
==
GIT_SUCCESS
)
goto
cleanup
;
}
if
((
error
=
reference_available
(
ref
->
owner
,
new_name
,
ref
->
name
))
<
GIT_SUCCESS
)
return
git__rethrow
(
error
,
"Failed to rename reference. Reference already exists"
);
...
...
@@ -1328,9 +1333,7 @@ int git_reference_rename(git_reference *ref, const char *new_name, int force)
git_hashtable_remove
(
ref
->
owner
->
references
.
loose_cache
,
old_name
);
}
/* build new path */
git_path_join
(
aux_path
,
ref
->
owner
->
path_repository
,
new_name
);
if
(
git_futils_exists
(
aux_path
)
==
GIT_SUCCESS
)
{
if
(
git_futils_isdir
(
aux_path
)
==
GIT_SUCCESS
)
{
if
((
error
=
git_futils_rmdir_r
(
aux_path
,
0
))
<
GIT_SUCCESS
)
...
...
tests/t10-refs.c
View file @
805dc2a0
...
...
@@ -751,6 +751,35 @@ BEGIN_TEST(rename8, "can be renamed to a new name prefixed with the old name")
close_temp_repo
(
repo
);
END_TEST
BEGIN_TEST
(
rename9
,
"can move a reference to a upper reference hierarchy"
)
git_reference
*
ref
,
*
ref_two
,
*
looked_up_ref
;
git_repository
*
repo
;
git_oid
id
;
must_pass
(
open_temp_repo
(
&
repo
,
REPOSITORY_FOLDER
));
must_pass
(
git_reference_lookup
(
&
ref
,
repo
,
ref_master_name
));
must_be_true
(
ref
->
type
&
GIT_REF_OID
);
git_oid_cpy
(
&
id
,
git_reference_oid
(
ref
));
/* Create loose references */
must_pass
(
git_reference_create_oid
(
&
ref_two
,
repo
,
ref_two_name_new
,
&
id
,
0
));
/* An existing reference... */
must_pass
(
git_reference_lookup
(
&
looked_up_ref
,
repo
,
ref_two_name_new
));
/* Can be renamed upward the reference tree. */
must_pass
(
git_reference_rename
(
looked_up_ref
,
ref_two_name
,
0
));
/* Check we actually renamed it */
must_pass
(
git_reference_lookup
(
&
looked_up_ref
,
repo
,
ref_two_name
));
must_be_true
(
!
strcmp
(
looked_up_ref
->
name
,
ref_two_name
));
must_fail
(
git_reference_lookup
(
&
looked_up_ref
,
repo
,
ref_two_name_new
));
close_temp_repo
(
repo
);
END_TEST
BEGIN_TEST
(
delete0
,
"deleting a ref which is both packed and loose should remove both tracks in the filesystem"
)
git_reference
*
looked_up_ref
,
*
another_looked_up_ref
;
git_repository
*
repo
;
...
...
@@ -1141,6 +1170,7 @@ BEGIN_SUITE(refs)
ADD_TEST
(
rename6
);
ADD_TEST
(
rename7
);
ADD_TEST
(
rename8
);
ADD_TEST
(
rename9
);
ADD_TEST
(
delete0
);
...
...
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