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
77db6ff5
Commit
77db6ff5
authored
Sep 21, 2013
by
Ben Straub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify blob loading logic
parent
f0c9d8ba
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
22 deletions
+17
-22
src/blame.c
+17
-22
No files found.
src/blame.c
View file @
77db6ff5
...
...
@@ -256,6 +256,22 @@ static git_blame_hunk* hunk_from_entry(git_blame__entry *e)
return
h
;
}
static
int
load_blob
(
git_blame
*
blame
)
{
int
error
;
error
=
git_commit_lookup
(
&
blame
->
final
,
blame
->
repository
,
&
blame
->
options
.
newest_commit
);
if
(
error
<
0
)
goto
cleanup
;
error
=
git_object_lookup_bypath
((
git_object
**
)
&
blame
->
final_blob
,
(
git_object
*
)
blame
->
final
,
blame
->
path
,
GIT_OBJ_BLOB
);
if
(
error
<
0
)
goto
cleanup
;
cleanup:
return
error
;
}
static
int
blame_internal
(
git_blame
*
blame
)
{
int
error
;
...
...
@@ -309,27 +325,6 @@ cleanup:
* File blaming
******************************************************************************/
static
int
load_blob
(
git_blame
*
blame
,
git_repository
*
repo
,
git_oid
*
commit_id
,
const
char
*
path
)
{
int
retval
=
-
1
;
git_commit
*
commit
=
NULL
;
git_tree
*
tree
=
NULL
;
git_tree_entry
*
tree_entry
=
NULL
;
git_object
*
obj
=
NULL
;
if
(((
retval
=
git_commit_lookup
(
&
commit
,
repo
,
commit_id
))
<
0
)
||
((
retval
=
git_object_lookup_bypath
(
&
obj
,
(
git_object
*
)
commit
,
path
,
GIT_OBJ_BLOB
))
<
0
)
||
((
retval
=
git_object_type
(
obj
))
!=
GIT_OBJ_BLOB
))
goto
cleanup
;
blame
->
final_blob
=
(
git_blob
*
)
obj
;
cleanup:
git_tree_entry_free
(
tree_entry
);
git_tree_free
(
tree
);
git_commit_free
(
commit
);
return
retval
;
}
int
git_blame_file
(
git_blame
**
out
,
git_repository
*
repo
,
...
...
@@ -346,7 +341,7 @@ int git_blame_file(
blame
=
git_blame__alloc
(
repo
,
normOptions
,
path
);
GITERR_CHECK_ALLOC
(
blame
);
if
((
error
=
load_blob
(
blame
,
repo
,
&
normOptions
.
newest_commit
,
path
))
<
0
)
if
((
error
=
load_blob
(
blame
))
<
0
)
goto
on_error
;
if
((
error
=
blame_internal
(
blame
))
<
0
)
...
...
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