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
387d01b8
Commit
387d01b8
authored
Apr 27, 2012
by
Ben Straub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented rev-parse "^{type}" syntax.
parent
9d7bdf71
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
20 deletions
+22
-20
src/revparse.c
+14
-14
tests-clar/refs/revparse.c
+8
-6
No files found.
src/revparse.c
View file @
387d01b8
...
...
@@ -116,7 +116,7 @@ static int revparse_lookup_object(git_object **out, git_repository *repo, const
static
int
walk_ref_history
(
git_object
**
out
,
const
char
*
refspec
,
const
char
*
reflogspec
)
{
/
/ TODO
/
* TODO */
/* Empty refspec means current branch */
...
...
@@ -134,25 +134,25 @@ static git_object* dereference_object(git_object *obj)
{
git_otype
type
=
git_object_type
(
obj
);
git_object
*
newobj
=
NULL
;
git_tree
*
tree
=
NULL
;
switch
(
type
)
{
case
GIT_OBJ_COMMIT
:
break
;
case
GIT_OBJ_TREE
:
break
;
case
GIT_OBJ_BLOB
:
if
(
0
==
git_commit_tree
(
&
tree
,
(
git_commit
*
)
obj
))
{
return
(
git_object
*
)
tree
;
}
break
;
case
GIT_OBJ_TAG
:
if
(
0
==
git_tag_target
(
&
newobj
,
(
git_tag
*
)
obj
))
{
return
newobj
;
}
break
;
case
GIT_OBJ_OFS_DELTA
:
break
;
case
GIT_OBJ_REF_DELTA
:
break
;
default:
case
GIT_OBJ_TREE
:
case
GIT_OBJ_BLOB
:
case
GIT_OBJ_OFS_DELTA
:
case
GIT_OBJ_REF_DELTA
:
break
;
}
...
...
@@ -168,14 +168,14 @@ static int dereference_to_type(git_object **out, git_object *obj, git_otype targ
git_otype
this_type
=
git_object_type
(
obj1
);
if
(
this_type
==
target_type
)
{
*
out
=
obj
;
*
out
=
obj
1
;
return
0
;
}
/* Dereference once, if possible. */
obj2
=
dereference_object
(
obj1
);
if
(
obj
2
!=
obj
)
{
git_object_free
(
obj
2
);
if
(
obj
1
!=
obj
)
{
git_object_free
(
obj
1
);
}
obj1
=
obj2
;
}
...
...
@@ -212,7 +212,7 @@ static int handle_caret_syntax(git_object **out, git_object *obj, const char *mo
giterr_set
(
GITERR_REFERENCE
,
"Couldn't find object of target type."
);
return
GIT_ERROR
;
}
newobj
=
newobj
;
newobj
=
newobj
2
;
}
*
out
=
newobj2
;
return
0
;
...
...
@@ -220,7 +220,7 @@ static int handle_caret_syntax(git_object **out, git_object *obj, const char *mo
/* {/...} -> Walk all commits until we see a commit msg that matches the phrase. */
if
(
movement
[
1
]
==
'/'
)
{
/
/ TODO
/
* TODO */
return
GIT_ERROR
;
}
...
...
tests-clar/refs/revparse.c
View file @
387d01b8
...
...
@@ -7,7 +7,7 @@ static git_object *g_obj;
/
/ Hepers
/
* Helpers */
static
void
oid_str_cmp
(
const
git_object
*
obj
,
const
char
*
expected
)
{
char
objstr
[
64
]
=
{
0
};
...
...
@@ -35,7 +35,6 @@ void test_refs_revparse__nonexistant_object(void)
void
test_refs_revparse__shas
(
void
)
{
// Full SHA should return a valid object
cl_git_pass
(
git_revparse_single
(
&
g_obj
,
g_repo
,
"c47800c7266a2be04c571c04d5a6614691ea99bd"
));
oid_str_cmp
(
g_obj
,
"c47800c7266a2be04c571c04d5a6614691ea99bd"
);
cl_git_pass
(
git_revparse_single
(
&
g_obj
,
g_repo
,
"c47800c"
));
...
...
@@ -44,14 +43,12 @@ void test_refs_revparse__shas(void)
void
test_refs_revparse__head
(
void
)
{
// Named head should return a valid object
cl_git_pass
(
git_revparse_single
(
&
g_obj
,
g_repo
,
"HEAD"
));
oid_str_cmp
(
g_obj
,
"a65fedf39aefe402d3bb6e24df4d4f5fe4547750"
);
}
void
test_refs_revparse__full_refs
(
void
)
{
// Fully-qualified refs should return valid objects
cl_git_pass
(
git_revparse_single
(
&
g_obj
,
g_repo
,
"refs/heads/master"
));
oid_str_cmp
(
g_obj
,
"a65fedf39aefe402d3bb6e24df4d4f5fe4547750"
);
cl_git_pass
(
git_revparse_single
(
&
g_obj
,
g_repo
,
"refs/heads/test"
));
...
...
@@ -62,7 +59,6 @@ void test_refs_revparse__full_refs(void)
void
test_refs_revparse__partial_refs
(
void
)
{
// Partially-qualified refs should return valid objects
cl_git_pass
(
git_revparse_single
(
&
g_obj
,
g_repo
,
"point_to_blob"
));
oid_str_cmp
(
g_obj
,
"1385f264afb75a56a5bec74243be9b367ba4ca08"
);
cl_git_pass
(
git_revparse_single
(
&
g_obj
,
g_repo
,
"packed-test"
));
...
...
@@ -103,9 +99,15 @@ void test_refs_revparse__not_tag(void)
void
test_refs_revparse__to_type
(
void
)
{
cl_git_pass
(
git_revparse_single
(
&
g_obj
,
g_repo
,
"wrapped_tag^{commit}"
));
oid_str_cmp
(
g_obj
,
"a65fedf39aefe402d3bb6e24df4d4f5fe4547750"
);
cl_git_pass
(
git_revparse_single
(
&
g_obj
,
g_repo
,
"wrapped_tag^{tree}"
));
oid_str_cmp
(
g_obj
,
"944c0f6e4dfa41595e6eb3ceecdb14f50fe18162"
);
cl_git_pass
(
git_revparse_single
(
&
g_obj
,
g_repo
,
"point_to_blob^{blob}"
));
oid_str_cmp
(
g_obj
,
"1385f264afb75a56a5bec74243be9b367ba4ca08"
);
}
void
test_refs_revparse__reflog
(
void
)
{
/
/ TODO: how to create a fixture for this? git_reflog_write?
/
* TODO: how to create a fixture for this? git_reflog_write? */
}
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