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
cd1ef822
Commit
cd1ef822
authored
Oct 20, 2012
by
nulltoken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: extract make_head_orphaned() logic
parent
209e34fa
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
26 additions
and
28 deletions
+26
-28
tests-clar/checkout/head.c
+2
-4
tests-clar/refs/branches/delete.c
+2
-4
tests-clar/refs/branches/ishead.c
+2
-9
tests-clar/repo/head.c
+4
-11
tests-clar/repo/repo_helpers.c
+11
-0
tests-clar/repo/repo_helpers.h
+5
-0
No files found.
tests-clar/checkout/head.c
View file @
cd1ef822
#include "clar_libgit2.h"
#include "refs.h"
#include "repo/repo_helpers.h"
static
git_repository
*
g_repo
;
...
...
@@ -15,10 +16,7 @@ void test_checkout_head__cleanup(void)
void
test_checkout_head__checking_out_an_orphaned_head_returns_GIT_EORPHANEDHEAD
(
void
)
{
git_reference
*
head
;
cl_git_pass
(
git_reference_create_symbolic
(
&
head
,
g_repo
,
GIT_HEAD_FILE
,
"refs/heads/hide/and/seek"
,
1
));
git_reference_free
(
head
);
make_head_orphaned
(
g_repo
,
NON_EXISTING_HEAD
);
cl_assert_equal_i
(
GIT_EORPHANEDHEAD
,
git_checkout_head
(
g_repo
,
NULL
,
NULL
));
}
tests-clar/refs/branches/delete.c
View file @
cd1ef822
#include "clar_libgit2.h"
#include "refs.h"
#include "repo/repo_helpers.h"
static
git_repository
*
repo
;
static
git_reference
*
fake_remote
;
...
...
@@ -52,11 +53,9 @@ void test_refs_branches_delete__can_delete_a_branch_even_if_HEAD_is_missing(void
void
test_refs_branches_delete__can_delete_a_branch_when_HEAD_is_orphaned
(
void
)
{
git_reference
*
head
;
git_reference
*
branch
;
cl_git_pass
(
git_reference_create_symbolic
(
&
head
,
repo
,
GIT_HEAD_FILE
,
"refs/heads/hide/and/seek"
,
1
));
git_reference_free
(
head
);
make_head_orphaned
(
repo
,
NON_EXISTING_HEAD
);
cl_git_pass
(
git_branch_lookup
(
&
branch
,
repo
,
"br2"
,
GIT_BRANCH_LOCAL
));
cl_git_pass
(
git_branch_delete
(
branch
));
...
...
@@ -91,4 +90,3 @@ void test_refs_branches_delete__can_delete_a_remote_branch(void)
cl_git_pass
(
git_branch_lookup
(
&
branch
,
repo
,
"nulltoken/master"
,
GIT_BRANCH_REMOTE
));
cl_git_pass
(
git_branch_delete
(
branch
));
}
tests-clar/refs/branches/ishead.c
View file @
cd1ef822
#include "clar_libgit2.h"
#include "refs.h"
#include "repo/repo_helpers.h"
static
git_repository
*
repo
;
static
git_reference
*
branch
;
...
...
@@ -22,21 +23,13 @@ void test_refs_branches_ishead__can_tell_if_a_branch_is_pointed_at_by_HEAD(void)
cl_assert_equal_i
(
true
,
git_branch_is_head
(
branch
));
}
static
void
make_head_orphaned
(
void
)
{
git_reference
*
head
;
cl_git_pass
(
git_reference_create_symbolic
(
&
head
,
repo
,
GIT_HEAD_FILE
,
"refs/heads/hide/and/seek"
,
1
));
git_reference_free
(
head
);
}
void
test_refs_branches_ishead__can_properly_handle_orphaned_HEAD
(
void
)
{
git_repository_free
(
repo
);
repo
=
cl_git_sandbox_init
(
"testrepo.git"
);
make_head_orphaned
();
make_head_orphaned
(
repo
,
NON_EXISTING_HEAD
);
cl_git_pass
(
git_reference_lookup
(
&
branch
,
repo
,
"refs/heads/master"
));
...
...
tests-clar/repo/head.c
View file @
cd1ef822
#include "clar_libgit2.h"
#include "refs.h"
#include "repo_helpers.h"
git_repository
*
repo
;
...
...
@@ -30,21 +31,13 @@ void test_repo_head__head_detached(void)
cl_assert_equal_i
(
false
,
git_repository_head_detached
(
repo
));
}
static
void
make_head_orphaned
(
void
)
{
git_reference
*
head
;
cl_git_pass
(
git_reference_create_symbolic
(
&
head
,
repo
,
GIT_HEAD_FILE
,
"refs/heads/hide/and/seek"
,
1
));
git_reference_free
(
head
);
}
void
test_repo_head__head_orphan
(
void
)
{
git_reference
*
ref
;
cl_assert
(
git_repository_head_orphan
(
repo
)
==
0
);
make_head_orphaned
();
make_head_orphaned
(
repo
,
NON_EXISTING_HEAD
);
cl_assert
(
git_repository_head_orphan
(
repo
)
==
1
);
...
...
@@ -171,7 +164,7 @@ void test_repo_head__detach_head_Fails_if_HEAD_and_point_to_a_non_commitish(void
void
test_repo_head__detaching_an_orphaned_head_returns_GIT_EORPHANEDHEAD
(
void
)
{
make_head_orphaned
();
make_head_orphaned
(
repo
,
NON_EXISTING_HEAD
);
cl_assert_equal_i
(
GIT_EORPHANEDHEAD
,
git_repository_detach_head
(
repo
));
}
...
...
@@ -180,7 +173,7 @@ void test_repo_head__retrieving_an_orphaned_head_returns_GIT_EORPHANEDHEAD(void)
{
git_reference
*
head
;
make_head_orphaned
();
make_head_orphaned
(
repo
,
NON_EXISTING_HEAD
);
cl_assert_equal_i
(
GIT_EORPHANEDHEAD
,
git_repository_head
(
&
head
,
repo
));
}
tests-clar/repo/repo_helpers.c
0 → 100644
View file @
cd1ef822
#include "clar_libgit2.h"
#include "refs.h"
#include "repo_helpers.h"
void
make_head_orphaned
(
git_repository
*
repo
,
const
char
*
target
)
{
git_reference
*
head
;
cl_git_pass
(
git_reference_create_symbolic
(
&
head
,
repo
,
GIT_HEAD_FILE
,
target
,
1
));
git_reference_free
(
head
);
}
tests-clar/repo/repo_helpers.h
0 → 100644
View file @
cd1ef822
#include "common.h"
#define NON_EXISTING_HEAD "refs/heads/hide/and/seek"
extern
void
make_head_orphaned
(
git_repository
*
repo
,
const
char
*
target
);
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