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
c1ca2b67
Commit
c1ca2b67
authored
Oct 10, 2013
by
Ben Straub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include signatures in blame hunks
parent
ebd67243
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
6 deletions
+10
-6
examples/blame.c
+4
-6
include/git2/blame.h
+2
-0
src/blame.c
+4
-0
No files found.
examples/blame.c
View file @
c1ca2b67
...
...
@@ -128,22 +128,20 @@ int main(int argc, char *argv[])
while
(
i
<
git_blob_rawsize
(
blob
))
{
const
char
*
eol
=
strchr
(
rawdata
+
i
,
'\n'
);
char
oid
[
10
]
=
{
0
};
git_commit
*
hunkcommit
;
const
git_signature
*
sig
;
const
git_blame_hunk
*
hunk
=
git_blame_get_hunk_byline
(
blame
,
line
);
if
(
hunk
)
{
char
sig
[
128
]
=
{
0
};
git_oid_tostr
(
oid
,
10
,
&
hunk
->
final_commit_id
);
check
(
git_commit_lookup
(
&
hunkcommit
,
repo
,
&
hunk
->
final_commit_id
),
"Commit lookup error"
);
sig
=
git_commit_author
(
hunkcommit
);
snprintf
(
sig
,
30
,
"%s <%s>"
,
hunk
->
final_signature
->
name
,
hunk
->
final_signature
->
email
);
printf
(
"%s ( %-30s %3d) %.*s
\n
"
,
oid
,
sig
->
name
,
sig
,
line
,
(
int
)(
eol
-
rawdata
-
i
),
rawdata
+
i
);
git_commit_free
(
hunkcommit
);
}
i
=
eol
-
rawdata
+
1
;
...
...
include/git2/blame.h
View file @
c1ca2b67
...
...
@@ -103,10 +103,12 @@ typedef struct git_blame_hunk {
git_oid
final_commit_id
;
uint16_t
final_start_line_number
;
git_signature
*
final_signature
;
git_oid
orig_commit_id
;
const
char
*
orig_path
;
uint16_t
orig_start_line_number
;
git_signature
*
orig_signature
;
char
boundary
;
}
git_blame_hunk
;
...
...
src/blame.c
View file @
c1ca2b67
...
...
@@ -12,6 +12,7 @@
#include "git2/tree.h"
#include "git2/diff.h"
#include "git2/blob.h"
#include "git2/signature.h"
#include "util.h"
#include "repository.h"
#include "blame_git.h"
...
...
@@ -80,6 +81,8 @@ static git_blame_hunk* dup_hunk(git_blame_hunk *hunk)
static
void
free_hunk
(
git_blame_hunk
*
hunk
)
{
git__free
((
void
*
)
hunk
->
orig_path
);
git_signature_free
(
hunk
->
final_signature
);
git_signature_free
(
hunk
->
orig_signature
);
git__free
(
hunk
);
}
...
...
@@ -252,6 +255,7 @@ static git_blame_hunk* hunk_from_entry(git_blame__entry *e)
git_blame_hunk
*
h
=
new_hunk
(
e
->
lno
+
1
,
e
->
num_lines
,
e
->
s_lno
+
1
,
e
->
suspect
->
path
);
git_oid_cpy
(
&
h
->
final_commit_id
,
git_commit_id
(
e
->
suspect
->
commit
));
h
->
final_signature
=
git_signature_dup
(
git_commit_author
(
e
->
suspect
->
commit
));
h
->
boundary
=
e
->
is_boundary
?
1
:
0
;
return
h
;
}
...
...
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