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
7ac1b899
Commit
7ac1b899
authored
Feb 01, 2014
by
Ben Straub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add failing test case
parent
40e10630
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
13 deletions
+38
-13
tests/repo/head.c
+38
-13
No files found.
tests/repo/head.c
View file @
7ac1b899
...
...
@@ -195,10 +195,41 @@ 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
)
static
void
test_reflog
(
git_repository
*
repo
,
size_t
idx
,
const
char
*
old_spec
,
const
char
*
new_spec
,
const
char
*
email
,
const
char
*
message
)
{
git_reflog
*
log
;
const
git_reflog_entry
*
entry1
,
*
entry2
,
*
entry3
;
git_reflog_entry
*
entry
;
cl_git_pass
(
git_reflog_read
(
&
log
,
repo
,
"HEAD"
));
entry
=
git_reflog_entry_byindex
(
log
,
idx
);
if
(
old_spec
)
{
git_object
*
obj
;
cl_git_pass
(
git_revparse_single
(
&
obj
,
repo
,
old_spec
));
cl_assert_equal_i
(
0
,
git_oid_cmp
(
git_object_id
(
obj
),
git_reflog_entry_id_old
(
entry
)));
git_object_free
(
obj
);
}
if
(
new_spec
)
{
git_object
*
obj
;
cl_git_pass
(
git_revparse_single
(
&
obj
,
repo
,
new_spec
));
cl_assert_equal_i
(
0
,
git_oid_cmp
(
git_object_id
(
obj
),
git_reflog_entry_id_new
(
entry
)));
git_object_free
(
obj
);
}
if
(
email
)
{
cl_assert_equal_s
(
email
,
git_reflog_entry_committer
(
entry
)
->
email
);
}
if
(
message
)
{
cl_assert_equal_s
(
message
,
git_reflog_entry_message
(
entry
));
}
git_reflog_free
(
log
);
}
void
test_repo_head__setting_head_updates_reflog
(
void
)
{
git_object
*
tag
;
git_signature
*
sig
;
...
...
@@ -208,19 +239,13 @@ void test_repo_head__setting_head_updates_reflog(void)
cl_git_pass
(
git_repository_set_head
(
repo
,
"refs/heads/unborn"
,
sig
,
"message2"
));
cl_git_pass
(
git_revparse_single
(
&
tag
,
repo
,
"tags/test"
));
cl_git_pass
(
git_repository_set_head_detached
(
repo
,
git_object_id
(
tag
),
sig
,
"message3"
));
cl_git_pass
(
git_repository_set_head
(
repo
,
"refs/heads/haacked"
,
sig
,
"message4"
));
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
));
cl_assert_equal_s
(
"foo@example.com"
,
git_reflog_entry_committer
(
entry1
)
->
email
);
cl_assert_equal_s
(
"foo@example.com"
,
git_reflog_entry_committer
(
entry2
)
->
email
);
cl_assert_equal_s
(
"foo@example.com"
,
git_reflog_entry_committer
(
entry3
)
->
email
);
test_reflog
(
repo
,
3
,
NULL
,
"refs/heads/haacked"
,
"foo@example.com"
,
"message1"
);
test_reflog
(
repo
,
2
,
"refs/heads/haacked"
,
NULL
,
"foo@example.com"
,
"message2"
);
test_reflog
(
repo
,
1
,
NULL
,
"tags/test^{commit}"
,
"foo@example.com"
,
"message3"
);
test_reflog
(
repo
,
0
,
"tags/test^{commit}"
,
"refs/heads/haacked"
,
"foo@example.com"
,
"message4"
);
git_reflog_free
(
log
);
git_object_free
(
tag
);
git_signature_free
(
sig
);
}
...
...
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