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
e2c81fca
Commit
e2c81fca
authored
Jul 15, 2012
by
nulltoken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revparse: deploy git_object_peel()
parent
db9be945
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
55 deletions
+4
-55
src/revparse.c
+4
-55
No files found.
src/revparse.c
View file @
e2c81fca
...
...
@@ -382,57 +382,6 @@ cleanup:
return
error
;
}
static
int
dereference_object
(
git_object
**
dereferenced
,
git_object
*
obj
)
{
git_otype
type
=
git_object_type
(
obj
);
switch
(
type
)
{
case
GIT_OBJ_COMMIT
:
return
git_commit_tree
((
git_tree
**
)
dereferenced
,
(
git_commit
*
)
obj
);
break
;
case
GIT_OBJ_TAG
:
return
git_tag_target
(
dereferenced
,
(
git_tag
*
)
obj
);
break
;
default:
return
GIT_ENOTFOUND
;
break
;
}
}
static
int
dereference_to_type
(
git_object
**
out
,
git_object
*
obj
,
git_otype
target_type
)
{
git_object
*
source
,
*
deref
=
NULL
;
if
(
git_object_type
(
obj
)
==
target_type
)
return
git_object_lookup
(
out
,
git_object_owner
(
obj
),
git_object_id
(
obj
),
target_type
);
source
=
obj
;
while
(
true
)
{
if
(
dereference_object
(
&
deref
,
source
)
<
0
)
goto
cleanup
;
if
(
source
!=
obj
)
git_object_free
(
source
);
if
(
git_object_type
(
deref
)
==
target_type
)
{
*
out
=
deref
;
return
0
;
}
source
=
deref
;
deref
=
NULL
;
}
cleanup:
if
(
source
!=
obj
)
git_object_free
(
source
);
git_object_free
(
deref
);
return
-
1
;
}
static
git_otype
parse_obj_type
(
const
char
*
str
)
{
if
(
!
strcmp
(
str
,
"commit"
))
...
...
@@ -463,7 +412,7 @@ static int handle_caret_parent_syntax(git_object **out, git_object *obj, int n)
git_object
*
temp_commit
=
NULL
;
int
error
;
if
(
dereference_to_type
(
&
temp_commit
,
obj
,
GIT_OBJ_COMMIT
)
<
0
)
if
(
git_object_peel
(
&
temp_commit
,
obj
,
GIT_OBJ_COMMIT
)
<
0
)
return
-
1
;
if
(
n
==
0
)
{
...
...
@@ -482,7 +431,7 @@ static int handle_linear_syntax(git_object **out, git_object *obj, int n)
git_object
*
temp_commit
=
NULL
;
int
error
;
if
(
dereference_to_type
(
&
temp_commit
,
obj
,
GIT_OBJ_COMMIT
)
<
0
)
if
(
git_object_peel
(
&
temp_commit
,
obj
,
GIT_OBJ_COMMIT
)
<
0
)
return
-
1
;
error
=
git_commit_nth_gen_ancestor
((
git_commit
**
)
out
,
(
git_commit
*
)
temp_commit
,
n
);
...
...
@@ -500,7 +449,7 @@ static int handle_colon_syntax(
int
error
=
-
1
;
git_tree_entry
*
entry
=
NULL
;
if
(
dereference_to_type
(
&
tree
,
obj
,
GIT_OBJ_TREE
)
<
0
)
if
(
git_object_peel
(
&
tree
,
obj
,
GIT_OBJ_TREE
)
<
0
)
return
-
1
;
if
(
*
path
==
'\0'
)
{
...
...
@@ -595,7 +544,7 @@ static int handle_caret_curly_syntax(git_object **out, git_object *obj, const ch
if
(
expected_type
==
GIT_OBJ_BAD
)
return
-
1
;
return
dereference_to_type
(
out
,
obj
,
expected_type
);
return
git_object_peel
(
out
,
obj
,
expected_type
);
}
static
int
extract_curly_braces_content
(
git_buf
*
buf
,
const
char
*
spec
,
int
*
pos
)
...
...
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