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
a121e580
Commit
a121e580
authored
Sep 20, 2013
by
Ben Straub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add typedefs for internal structs
parent
25c47aae
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
82 additions
and
78 deletions
+82
-78
src/blame.c
+7
-7
src/blame_git.c
+57
-53
src/blame_git.h
+18
-18
No files found.
src/blame.c
View file @
a121e580
...
@@ -221,7 +221,7 @@ static git_blame_hunk *split_hunk_in_vector(
...
@@ -221,7 +221,7 @@ static git_blame_hunk *split_hunk_in_vector(
* To allow quick access to the contents of nth line in the
* To allow quick access to the contents of nth line in the
* final image, prepare an index in the scoreboard.
* final image, prepare an index in the scoreboard.
*/
*/
static
int
prepare_lines
(
struct
scoreboard
*
sb
)
static
int
prepare_lines
(
git_blame__
scoreboard
*
sb
)
{
{
const
char
*
buf
=
sb
->
final_buf
;
const
char
*
buf
=
sb
->
final_buf
;
git_off_t
len
=
sb
->
final_buf_size
;
git_off_t
len
=
sb
->
final_buf_size
;
...
@@ -242,7 +242,7 @@ static int prepare_lines(struct scoreboard *sb)
...
@@ -242,7 +242,7 @@ static int prepare_lines(struct scoreboard *sb)
return
sb
->
num_lines
;
return
sb
->
num_lines
;
}
}
static
git_blame_hunk
*
hunk_from_entry
(
struct
blame
_entry
*
e
)
static
git_blame_hunk
*
hunk_from_entry
(
git_blame_
_entry
*
e
)
{
{
git_blame_hunk
*
h
=
new_hunk
(
git_blame_hunk
*
h
=
new_hunk
(
e
->
lno
+
1
,
e
->
num_lines
,
e
->
s_lno
+
1
,
e
->
suspect
->
path
);
e
->
lno
+
1
,
e
->
num_lines
,
e
->
s_lno
+
1
,
e
->
suspect
->
path
);
...
@@ -255,10 +255,10 @@ static int walk_and_mark(git_blame *blame)
...
@@ -255,10 +255,10 @@ static int walk_and_mark(git_blame *blame)
{
{
int
error
;
int
error
;
struct
scoreboard
sb
=
{
0
};
git_blame__
scoreboard
sb
=
{
0
};
struct
blame
_entry
*
ent
=
NULL
;
git_blame_
_entry
*
ent
=
NULL
;
git_blob
*
blob
=
NULL
;
git_blob
*
blob
=
NULL
;
struct
origin
*
o
;
git_blame__
origin
*
o
;
if
((
error
=
git_commit_lookup
(
&
sb
.
final
,
blame
->
repository
,
&
blame
->
options
.
newest_commit
))
<
0
||
if
((
error
=
git_commit_lookup
(
&
sb
.
final
,
blame
->
repository
,
&
blame
->
options
.
newest_commit
))
<
0
||
(
error
=
git_object_lookup_bypath
((
git_object
**
)
&
blob
,
(
git_object
*
)
sb
.
final
,
blame
->
path
,
GIT_OBJ_BLOB
))
<
0
)
(
error
=
git_object_lookup_bypath
((
git_object
**
)
&
blob
,
(
git_object
*
)
sb
.
final
,
blame
->
path
,
GIT_OBJ_BLOB
))
<
0
)
...
@@ -287,8 +287,8 @@ static int walk_and_mark(git_blame *blame)
...
@@ -287,8 +287,8 @@ static int walk_and_mark(git_blame *blame)
cleanup:
cleanup:
for
(
ent
=
sb
.
ent
;
ent
;
)
{
for
(
ent
=
sb
.
ent
;
ent
;
)
{
struct
blame
_entry
*
e
=
ent
->
next
;
git_blame_
_entry
*
e
=
ent
->
next
;
struct
origin
*
o
=
ent
->
suspect
;
git_blame__
origin
*
o
=
ent
->
suspect
;
git_vector_insert
(
&
blame
->
hunks
,
hunk_from_entry
(
ent
));
git_vector_insert
(
&
blame
->
hunks
,
hunk_from_entry
(
ent
));
...
...
src/blame_git.c
View file @
a121e580
This diff is collapsed.
Click to expand it.
src/blame_git.h
View file @
a121e580
...
@@ -9,22 +9,22 @@
...
@@ -9,22 +9,22 @@
/*
/*
* One blob in a commit that is being suspected
* One blob in a commit that is being suspected
*/
*/
struct
origin
{
typedef
struct
git_blame__
origin
{
int
refcnt
;
int
refcnt
;
struct
origin
*
previous
;
struct
git_blame__
origin
*
previous
;
git_commit
*
commit
;
git_commit
*
commit
;
git_blob
*
blob
;
git_blob
*
blob
;
char
path
[];
char
path
[];
};
}
git_blame__origin
;
/*
/*
* Each group of lines is described by a
blame
_entry; it can be split
* Each group of lines is described by a
git_blame_
_entry; it can be split
* as we pass blame to the parents. They form a linked list in the
* as we pass blame to the parents. They form a linked list in the
* scoreboard structure, sorted by the target line number.
* scoreboard structure, sorted by the target line number.
*/
*/
struct
blame
_entry
{
typedef
struct
git_blame_
_entry
{
struct
blame
_entry
*
prev
;
struct
git_blame_
_entry
*
prev
;
struct
blame
_entry
*
next
;
struct
git_blame_
_entry
*
next
;
/* the first line of this group in the final image;
/* the first line of this group in the final image;
* internally all line numbers are 0 based.
* internally all line numbers are 0 based.
...
@@ -35,7 +35,7 @@ struct blame_entry {
...
@@ -35,7 +35,7 @@ struct blame_entry {
int
num_lines
;
int
num_lines
;
/* the commit that introduced this group into the final image */
/* the commit that introduced this group into the final image */
struct
origin
*
suspect
;
git_blame__
origin
*
suspect
;
/* true if the suspect is truly guilty; false while we have not
/* true if the suspect is truly guilty; false while we have not
* checked if the group came from one of its parents.
* checked if the group came from one of its parents.
...
@@ -59,12 +59,12 @@ struct blame_entry {
...
@@ -59,12 +59,12 @@ struct blame_entry {
/* Whether this entry has been tracked to a boundary commit.
/* Whether this entry has been tracked to a boundary commit.
*/
*/
bool
is_boundary
;
bool
is_boundary
;
};
}
git_blame__entry
;
/*
/*
* The current state of the blame assignment.
* The current state of the blame assignment.
*/
*/
struct
scoreboard
{
typedef
struct
git_blame__
scoreboard
{
/* the final commit (i.e. where we started digging from) */
/* the final commit (i.e. where we started digging from) */
git_commit
*
final
;
git_commit
*
final
;
const
char
*
path
;
const
char
*
path
;
...
@@ -78,20 +78,20 @@ struct scoreboard {
...
@@ -78,20 +78,20 @@ struct scoreboard {
git_off_t
final_buf_size
;
git_off_t
final_buf_size
;
/* linked list of blames */
/* linked list of blames */
struct
blame
_entry
*
ent
;
git_blame_
_entry
*
ent
;
/* look-up a line in the final buffer */
/* look-up a line in the final buffer */
int
num_lines
;
int
num_lines
;
git_blame
*
blame
;
git_blame
*
blame
;
};
}
git_blame__scoreboard
;
int
get_origin
(
struct
origin
**
out
,
struct
scoreboard
*
sb
,
git_commit
*
commit
,
const
char
*
path
);
int
get_origin
(
git_blame__origin
**
out
,
git_blame__
scoreboard
*
sb
,
git_commit
*
commit
,
const
char
*
path
);
int
make_origin
(
struct
origin
**
out
,
git_commit
*
commit
,
const
char
*
path
);
int
make_origin
(
git_blame__
origin
**
out
,
git_commit
*
commit
,
const
char
*
path
);
struct
origin
*
origin_incref
(
struct
origin
*
o
);
git_blame__origin
*
origin_incref
(
git_blame__
origin
*
o
);
void
origin_decref
(
struct
origin
*
o
);
void
origin_decref
(
git_blame__
origin
*
o
);
void
assign_blame
(
struct
scoreboard
*
sb
,
uint32_t
flags
);
void
assign_blame
(
git_blame__
scoreboard
*
sb
,
uint32_t
flags
);
void
coalesce
(
struct
scoreboard
*
sb
);
void
coalesce
(
git_blame__
scoreboard
*
sb
);
#endif
#endif
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