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
209e34fa
Commit
209e34fa
authored
Oct 20, 2012
by
nulltoken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: leverage git_repository_detach_head()
parent
c497a63b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
25 deletions
+13
-25
tests-clar/refs/branches/delete.c
+7
-5
tests-clar/repo/head.c
+5
-8
tests-clar/reset/soft.c
+1
-12
No files found.
tests-clar/refs/branches/delete.c
View file @
209e34fa
...
@@ -64,13 +64,15 @@ void test_refs_branches_delete__can_delete_a_branch_when_HEAD_is_orphaned(void)
...
@@ -64,13 +64,15 @@ void test_refs_branches_delete__can_delete_a_branch_when_HEAD_is_orphaned(void)
void
test_refs_branches_delete__can_delete_a_branch_pointed_at_by_detached_HEAD
(
void
)
void
test_refs_branches_delete__can_delete_a_branch_pointed_at_by_detached_HEAD
(
void
)
{
{
git_reference
*
master
,
*
head
,
*
branch
;
git_reference
*
head
,
*
branch
;
/* Detach HEAD and make it target the commit that "master" points to */
cl_git_pass
(
git_reference_lookup
(
&
head
,
repo
,
GIT_HEAD_FILE
));
cl_
git_pass
(
git_reference_lookup
(
&
master
,
repo
,
"refs/heads/master"
));
cl_
assert_equal_i
(
GIT_REF_SYMBOLIC
,
git_reference_type
(
head
));
cl_
git_pass
(
git_reference_create_oid
(
&
head
,
repo
,
"HEAD"
,
git_reference_oid
(
master
),
1
));
cl_
assert_equal_s
(
"refs/heads/master"
,
git_reference_target
(
head
));
git_reference_free
(
head
);
git_reference_free
(
head
);
git_reference_free
(
master
);
/* Detach HEAD and make it target the commit that "master" points to */
git_repository_detach_head
(
repo
);
cl_git_pass
(
git_branch_lookup
(
&
branch
,
repo
,
"master"
,
GIT_BRANCH_LOCAL
));
cl_git_pass
(
git_branch_lookup
(
&
branch
,
repo
,
"master"
,
GIT_BRANCH_LOCAL
));
cl_git_pass
(
git_branch_delete
(
branch
));
cl_git_pass
(
git_branch_delete
(
branch
));
...
...
tests-clar/repo/head.c
View file @
209e34fa
...
@@ -16,21 +16,18 @@ void test_repo_head__cleanup(void)
...
@@ -16,21 +16,18 @@ void test_repo_head__cleanup(void)
void
test_repo_head__head_detached
(
void
)
void
test_repo_head__head_detached
(
void
)
{
{
git_reference
*
ref
;
git_reference
*
ref
;
git_oid
oid
;
cl_assert
(
git_repository_head_detached
(
repo
)
==
0
);
cl_assert
(
git_repository_head_detached
(
repo
)
==
0
);
/* detach the HEAD */
git_repository_detach_head
(
repo
);
git_oid_fromstr
(
&
oid
,
"c47800c7266a2be04c571c04d5a6614691ea99bd"
);
cl_git_pass
(
git_reference_create_oid
(
&
ref
,
repo
,
"HEAD"
,
&
oid
,
1
));
cl_assert_equal_i
(
true
,
git_repository_head_detached
(
repo
));
cl_assert
(
git_repository_head_detached
(
repo
)
==
1
);
git_reference_free
(
ref
);
/* take the reop back to it's original state */
/* take the reop back to it's original state */
cl_git_pass
(
git_reference_create_symbolic
(
&
ref
,
repo
,
"HEAD"
,
"refs/heads/master"
,
1
));
cl_git_pass
(
git_reference_create_symbolic
(
&
ref
,
repo
,
"HEAD"
,
"refs/heads/master"
,
1
));
cl_assert
(
git_repository_head_detached
(
repo
)
==
0
);
git_reference_free
(
ref
);
git_reference_free
(
ref
);
cl_assert_equal_i
(
false
,
git_repository_head_detached
(
repo
));
}
}
static
void
make_head_orphaned
(
void
)
static
void
make_head_orphaned
(
void
)
...
...
tests-clar/reset/soft.c
View file @
209e34fa
...
@@ -39,20 +39,9 @@ void test_reset_soft__can_reset_the_non_detached_Head_to_the_specified_commit(vo
...
@@ -39,20 +39,9 @@ void test_reset_soft__can_reset_the_non_detached_Head_to_the_specified_commit(vo
assert_reset_soft
(
false
);
assert_reset_soft
(
false
);
}
}
static
void
detach_head
(
void
)
{
git_reference
*
head
;
git_oid
oid
;
cl_git_pass
(
git_reference_name_to_oid
(
&
oid
,
repo
,
"HEAD"
));
cl_git_pass
(
git_reference_create_oid
(
&
head
,
repo
,
"HEAD"
,
&
oid
,
true
));
git_reference_free
(
head
);
}
void
test_reset_soft__can_reset_the_detached_Head_to_the_specified_commit
(
void
)
void
test_reset_soft__can_reset_the_detached_Head_to_the_specified_commit
(
void
)
{
{
detach_head
(
);
git_repository_detach_head
(
repo
);
assert_reset_soft
(
true
);
assert_reset_soft
(
true
);
}
}
...
...
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