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
d77a4f94
Commit
d77a4f94
authored
Mar 08, 2015
by
Carlos Martín Nieto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2963 from libgit2/cmn/rename-reflog
refdb: use the same id for old and new when renaming a reference
parents
01c3b184
d578b45f
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
1 deletions
+7
-1
CHANGELOG.md
+2
-0
src/refdb_fs.c
+1
-1
tests/refs/branches/move.c
+4
-0
No files found.
CHANGELOG.md
View file @
d77a4f94
...
@@ -30,6 +30,8 @@ v0.22 + 1
...
@@ -30,6 +30,8 @@ v0.22 + 1
*
`git_config_get_string_buf()`
provides a way to safely retrieve a
*
`git_config_get_string_buf()`
provides a way to safely retrieve a
string from a non-snapshot configuration.
string from a non-snapshot configuration.
*
Reference renaming now uses the right id for the old value.
### API removals
### API removals
### Breaking API changes
### Breaking API changes
...
...
src/refdb_fs.c
View file @
d77a4f94
...
@@ -1324,7 +1324,7 @@ static int refdb_fs_backend__rename(
...
@@ -1324,7 +1324,7 @@ static int refdb_fs_backend__rename(
/* Try to rename the refog; it's ok if the old doesn't exist */
/* Try to rename the refog; it's ok if the old doesn't exist */
error
=
refdb_reflog_fs__rename
(
_backend
,
old_name
,
new_name
);
error
=
refdb_reflog_fs__rename
(
_backend
,
old_name
,
new_name
);
if
(((
error
==
0
)
||
(
error
==
GIT_ENOTFOUND
))
&&
if
(((
error
==
0
)
||
(
error
==
GIT_ENOTFOUND
))
&&
((
error
=
reflog_append
(
backend
,
new
,
NULL
,
NULL
,
who
,
message
))
<
0
))
{
((
error
=
reflog_append
(
backend
,
new
,
git_reference_target
(
new
)
,
NULL
,
who
,
message
))
<
0
))
{
git_reference_free
(
new
);
git_reference_free
(
new
);
git_filebuf_cleanup
(
&
file
);
git_filebuf_cleanup
(
&
file
);
return
error
;
return
error
;
...
...
tests/refs/branches/move.c
View file @
d77a4f94
...
@@ -203,6 +203,7 @@ void test_refs_branches_move__default_reflog_message(void)
...
@@ -203,6 +203,7 @@ void test_refs_branches_move__default_reflog_message(void)
const
git_reflog_entry
*
entry
;
const
git_reflog_entry
*
entry
;
git_signature
*
sig
;
git_signature
*
sig
;
git_config
*
cfg
;
git_config
*
cfg
;
git_oid
id
;
cl_git_pass
(
git_repository_config
(
&
cfg
,
repo
));
cl_git_pass
(
git_repository_config
(
&
cfg
,
repo
));
cl_git_pass
(
git_config_set_string
(
cfg
,
"user.name"
,
"Foo Bar"
));
cl_git_pass
(
git_config_set_string
(
cfg
,
"user.name"
,
"Foo Bar"
));
...
@@ -212,6 +213,7 @@ void test_refs_branches_move__default_reflog_message(void)
...
@@ -212,6 +213,7 @@ void test_refs_branches_move__default_reflog_message(void)
cl_git_pass
(
git_signature_default
(
&
sig
,
repo
));
cl_git_pass
(
git_signature_default
(
&
sig
,
repo
));
cl_git_pass
(
git_reference_lookup
(
&
branch
,
repo
,
"refs/heads/master"
));
cl_git_pass
(
git_reference_lookup
(
&
branch
,
repo
,
"refs/heads/master"
));
git_oid_cpy
(
&
id
,
git_reference_target
(
branch
));
cl_git_pass
(
git_branch_move
(
&
new_branch
,
branch
,
"master2"
,
0
));
cl_git_pass
(
git_branch_move
(
&
new_branch
,
branch
,
"master2"
,
0
));
cl_git_pass
(
git_reflog_read
(
&
log
,
repo
,
git_reference_name
(
new_branch
)));
cl_git_pass
(
git_reflog_read
(
&
log
,
repo
,
git_reference_name
(
new_branch
)));
...
@@ -219,6 +221,8 @@ void test_refs_branches_move__default_reflog_message(void)
...
@@ -219,6 +221,8 @@ void test_refs_branches_move__default_reflog_message(void)
cl_assert_equal_s
(
"branch: renamed refs/heads/master to refs/heads/master2"
,
cl_assert_equal_s
(
"branch: renamed refs/heads/master to refs/heads/master2"
,
git_reflog_entry_message
(
entry
));
git_reflog_entry_message
(
entry
));
cl_assert_equal_s
(
sig
->
email
,
git_reflog_entry_committer
(
entry
)
->
email
);
cl_assert_equal_s
(
sig
->
email
,
git_reflog_entry_committer
(
entry
)
->
email
);
cl_assert_equal_oid
(
&
id
,
git_reflog_entry_id_old
(
entry
));
cl_assert_equal_oid
(
&
id
,
git_reflog_entry_id_new
(
entry
));
git_reference_free
(
branch
);
git_reference_free
(
branch
);
git_reference_free
(
new_branch
);
git_reference_free
(
new_branch
);
...
...
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