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
a2311f92
Commit
a2311f92
authored
Jan 27, 2014
by
Ben Straub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure updating HEAD updates reflog
parent
94f263f5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
3 deletions
+27
-3
src/refdb_fs.c
+4
-3
tests/repo/head.c
+23
-0
No files found.
src/refdb_fs.c
View file @
a2311f92
...
...
@@ -1434,12 +1434,12 @@ success:
static
int
reflog_append
(
refdb_fs_backend
*
backend
,
const
git_reference
*
ref
,
const
git_signature
*
who
,
const
char
*
message
)
{
int
error
;
git_oid
old_id
,
new_id
;
git_oid
old_id
,
new_id
=
{{
0
}}
;
git_buf
buf
=
GIT_BUF_INIT
,
path
=
GIT_BUF_INIT
;
git_repository
*
repo
=
backend
->
repo
;
/* Creation of symbolic references doesn't get a reflog entry */
if
(
ref
->
type
==
GIT_REF_SYMBOLIC
)
if
(
ref
->
type
==
GIT_REF_SYMBOLIC
&&
strcmp
(
ref
->
name
,
GIT_HEAD_FILE
)
)
return
0
;
error
=
git_reference_name_to_id
(
&
old_id
,
repo
,
ref
->
name
);
...
...
@@ -1450,7 +1450,8 @@ static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, co
if
(
error
<
0
)
return
error
;
git_oid_cpy
(
&
new_id
,
git_reference_target
(
ref
));
if
(
git_reference_target
(
ref
)
!=
NULL
)
git_oid_cpy
(
&
new_id
,
git_reference_target
(
ref
));
if
((
error
=
serialize_reflog_entry
(
&
buf
,
&
old_id
,
&
new_id
,
who
,
message
))
<
0
)
goto
cleanup
;
...
...
tests/repo/head.c
View file @
a2311f92
...
...
@@ -194,3 +194,26 @@ void test_repo_head__can_tell_if_an_unborn_head_is_detached(void)
cl_assert_equal_i
(
false
,
git_repository_head_detached
(
repo
));
}
void
test_repo_head__setting_head_updates_reflog
(
void
)
{
git_reflog
*
log
;
const
git_reflog_entry
*
entry1
,
*
entry2
,
*
entry3
;
git_object
*
tag
;
cl_git_pass
(
git_repository_set_head
(
repo
,
"refs/heads/haacked"
,
NULL
,
"message1"
));
cl_git_pass
(
git_repository_set_head
(
repo
,
"refs/heads/unborn"
,
NULL
,
"message2"
));
cl_git_pass
(
git_revparse_single
(
&
tag
,
repo
,
"tags/test"
));
cl_git_pass
(
git_repository_set_head_detached
(
repo
,
git_object_id
(
tag
),
NULL
,
"message3"
));
cl_git_pass
(
git_reflog_read
(
&
log
,
repo
,
"HEAD"
));
entry1
=
git_reflog_entry_byindex
(
log
,
2
);
entry2
=
git_reflog_entry_byindex
(
log
,
1
);
entry3
=
git_reflog_entry_byindex
(
log
,
0
);
cl_assert_equal_s
(
"message1"
,
git_reflog_entry_message
(
entry1
));
cl_assert_equal_s
(
"message2"
,
git_reflog_entry_message
(
entry2
));
cl_assert_equal_s
(
"message3"
,
git_reflog_entry_message
(
entry3
));
git_reflog_free
(
log
);
git_object_free
(
tag
);
}
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