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
35bed94f
Commit
35bed94f
authored
Jul 03, 2012
by
nulltoken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revparse: enhance refs/<name> coverage
parent
6a5136e5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
2 deletions
+57
-2
tests-clar/refs/revparse.c
+57
-2
No files found.
tests-clar/refs/revparse.c
View file @
35bed94f
#include "clar_libgit2.h"
#include "clar_libgit2.h"
#include "git2/revparse.h"
#include "git2/revparse.h"
#include "buffer.h"
#include "refs.h"
#include "path.h"
static
git_repository
*
g_repo
;
static
git_repository
*
g_repo
;
static
git_object
*
g_obj
;
static
git_object
*
g_obj
;
...
@@ -9,13 +12,13 @@ static char g_orig_tz[16] = {0};
...
@@ -9,13 +12,13 @@ static char g_orig_tz[16] = {0};
/* Helpers */
/* Helpers */
static
void
test_object
(
const
char
*
spec
,
const
char
*
expected_oid
)
static
void
test_object
_inrepo
(
const
char
*
spec
,
const
char
*
expected_oid
,
git_repository
*
repo
)
{
{
char
objstr
[
64
]
=
{
0
};
char
objstr
[
64
]
=
{
0
};
git_object
*
obj
=
NULL
;
git_object
*
obj
=
NULL
;
int
error
;
int
error
;
error
=
git_revparse_single
(
&
obj
,
g_
repo
,
spec
);
error
=
git_revparse_single
(
&
obj
,
repo
,
spec
);
if
(
expected_oid
!=
NULL
)
{
if
(
expected_oid
!=
NULL
)
{
cl_assert_equal_i
(
0
,
error
);
cl_assert_equal_i
(
0
,
error
);
...
@@ -27,6 +30,11 @@ static void test_object(const char *spec, const char *expected_oid)
...
@@ -27,6 +30,11 @@ static void test_object(const char *spec, const char *expected_oid)
git_object_free
(
obj
);
git_object_free
(
obj
);
}
}
static
void
test_object
(
const
char
*
spec
,
const
char
*
expected_oid
)
{
test_object_inrepo
(
spec
,
expected_oid
,
g_repo
);
}
void
test_refs_revparse__initialize
(
void
)
void
test_refs_revparse__initialize
(
void
)
{
{
char
*
tz
=
cl_getenv
(
"TZ"
);
char
*
tz
=
cl_getenv
(
"TZ"
);
...
@@ -149,6 +157,53 @@ void test_refs_revparse__reflog(void)
...
@@ -149,6 +157,53 @@ void test_refs_revparse__reflog(void)
test_object
(
"master@{u}"
,
"be3563ae3f795b2b4353bcce3a527ad0a4f7f644"
);
test_object
(
"master@{u}"
,
"be3563ae3f795b2b4353bcce3a527ad0a4f7f644"
);
}
}
static
void
create_fake_stash_reference_and_reflog
(
git_repository
*
repo
)
{
git_reference
*
master
;
git_buf
log_path
=
GIT_BUF_INIT
;
git_buf_joinpath
(
&
log_path
,
git_repository_path
(
repo
),
"logs/refs/fakestash"
);
cl_assert_equal_i
(
false
,
git_path_isfile
(
git_buf_cstr
(
&
log_path
)));
cl_git_pass
(
git_reference_lookup
(
&
master
,
repo
,
"refs/heads/master"
));
cl_git_pass
(
git_reference_rename
(
master
,
"refs/fakestash"
,
0
));
cl_assert_equal_i
(
true
,
git_path_isfile
(
git_buf_cstr
(
&
log_path
)));
git_buf_free
(
&
log_path
);
git_reference_free
(
master
);
}
void
test_refs_revparse__reflog_of_a_ref_under_refs
(
void
)
{
git_repository
*
repo
=
cl_git_sandbox_init
(
"testrepo.git"
);
test_object_inrepo
(
"refs/fakestash"
,
NULL
,
repo
);
create_fake_stash_reference_and_reflog
(
repo
);
/*
* $ git reflog -1 refs/fakestash
* a65fedf refs/fakestash@{0}: commit: checking in
*
* $ git reflog -1 refs/fakestash@{0}
* a65fedf refs/fakestash@{0}: commit: checking in
*
* $ git reflog -1 fakestash
* a65fedf fakestash@{0}: commit: checking in
*
* $ git reflog -1 fakestash@{0}
* a65fedf fakestash@{0}: commit: checking in
*/
test_object_inrepo
(
"refs/fakestash"
,
"a65fedf39aefe402d3bb6e24df4d4f5fe4547750"
,
repo
);
test_object_inrepo
(
"refs/fakestash@{0}"
,
"a65fedf39aefe402d3bb6e24df4d4f5fe4547750"
,
repo
);
test_object_inrepo
(
"fakestash"
,
"a65fedf39aefe402d3bb6e24df4d4f5fe4547750"
,
repo
);
test_object_inrepo
(
"fakestash@{0}"
,
"a65fedf39aefe402d3bb6e24df4d4f5fe4547750"
,
repo
);
cl_git_sandbox_cleanup
();
}
void
test_refs_revparse__revwalk
(
void
)
void
test_refs_revparse__revwalk
(
void
)
{
{
cl_git_fail
(
git_revparse_single
(
&
g_obj
,
g_repo
,
"master^{/not found in any commit}"
));
cl_git_fail
(
git_revparse_single
(
&
g_obj
,
g_repo
,
"master^{/not found in any commit}"
));
...
...
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