summaryrefslogtreecommitdiff
path: root/src/revparse.c
diff options
context:
space:
mode:
authorBen Straub <bstraub@github.com>2012-04-27 11:47:29 -0700
committerBen Straub <bstraub@github.com>2012-05-11 11:30:45 -0700
commit387d01b8578ebedc665d8fa707b8897f9a04f380 (patch)
tree040693e0b41a49c201d3615d5e2c19103a86123a /src/revparse.c
parent9d7bdf7119fe7858fdaa6e79283dacbf98c4128c (diff)
downloadlibgit2-387d01b8578ebedc665d8fa707b8897f9a04f380.tar.gz
Implemented rev-parse "^{type}" syntax.
Diffstat (limited to 'src/revparse.c')
-rw-r--r--src/revparse.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/revparse.c b/src/revparse.c
index da274f860..472cc7587 100644
--- a/src/revparse.c
+++ b/src/revparse.c
@@ -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 = obj1;
return 0;
}
/* Dereference once, if possible. */
obj2 = dereference_object(obj1);
- if (obj2 != obj) {
- git_object_free(obj2);
+ if (obj1 != obj) {
+ git_object_free(obj1);
}
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 = newobj2;
}
*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;
}