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
7dcb1c45
Commit
7dcb1c45
authored
Oct 28, 2013
by
Ben Straub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adjust for diff API changes
parent
42c8f8f8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
26 deletions
+19
-26
src/blame.c
+8
-15
src/blame_git.c
+11
-11
No files found.
src/blame.c
View file @
7dcb1c45
...
...
@@ -370,19 +370,15 @@ static bool hunk_is_bufferblame(git_blame_hunk *hunk)
static
int
buffer_hunk_cb
(
const
git_diff_delta
*
delta
,
const
git_diff_range
*
range
,
const
char
*
header
,
size_t
header_len
,
const
git_diff_hunk
*
hunk
,
void
*
payload
)
{
git_blame
*
blame
=
(
git_blame
*
)
payload
;
size_t
wedge_line
;
GIT_UNUSED
(
delta
);
GIT_UNUSED
(
header
);
GIT_UNUSED
(
header_len
);
wedge_line
=
(
range
->
old_lines
==
0
)
?
range
->
new_start
:
range
->
old_start
;
wedge_line
=
(
hunk
->
old_lines
==
0
)
?
hunk
->
new_start
:
hunk
->
old_start
;
blame
->
current_diff_line
=
wedge_line
;
/* If this hunk doesn't start between existing hunks, split a hunk up so it does */
...
...
@@ -398,18 +394,15 @@ static int buffer_hunk_cb(
static
int
ptrs_equal_cmp
(
const
void
*
a
,
const
void
*
b
)
{
return
a
<
b
?
-
1
:
a
>
b
?
1
:
0
;
}
static
int
buffer_line_cb
(
const
git_diff_delta
*
delta
,
const
git_diff_range
*
range
,
char
line_origin
,
const
char
*
content
,
size_t
content_len
,
const
git_diff_hunk
*
hunk
,
const
git_diff_line
*
line
,
void
*
payload
)
{
git_blame
*
blame
=
(
git_blame
*
)
payload
;
GIT_UNUSED
(
delta
);
GIT_UNUSED
(
range
);
GIT_UNUSED
(
content
);
GIT_UNUSED
(
content_len
);
GIT_UNUSED
(
hunk
);
GIT_UNUSED
(
line
);
#ifdef DO_DEBUG
{
...
...
@@ -418,7 +411,7 @@ static int buffer_line_cb(
}
#endif
if
(
line
_
origin
==
GIT_DIFF_LINE_ADDITION
)
{
if
(
line
->
origin
==
GIT_DIFF_LINE_ADDITION
)
{
if
(
hunk_is_bufferblame
(
blame
->
current_hunk
)
&&
hunk_ends_at_or_before_line
(
blame
->
current_hunk
,
blame
->
current_diff_line
))
{
/* Append to the current buffer-blame hunk */
...
...
@@ -433,7 +426,7 @@ static int buffer_line_cb(
blame
->
current_diff_line
++
;
}
if
(
line
_
origin
==
GIT_DIFF_LINE_DELETION
)
{
if
(
line
->
origin
==
GIT_DIFF_LINE_DELETION
)
{
/* Trim the line from the current hunk; remove it if it's now empty */
size_t
shift_base
=
blame
->
current_diff_line
+
blame
->
current_hunk
->
lines_in_hunk
+
1
;
...
...
src/blame_git.c
View file @
7dcb1c45
...
...
@@ -400,7 +400,7 @@ static git_blame__origin* find_origin(
git_blame__origin
*
origin
)
{
git_blame__origin
*
porigin
=
NULL
;
git_diff
_list
*
difflist
=
NULL
;
git_diff
*
difflist
=
NULL
;
git_diff_options
diffopts
=
GIT_DIFF_OPTIONS_INIT
;
git_tree
*
otree
=
NULL
,
*
ptree
=
NULL
;
...
...
@@ -427,7 +427,7 @@ static git_blame__origin* find_origin(
int
i
;
/* Generate a full diff between the two trees */
git_diff_
list_
free
(
difflist
);
git_diff_free
(
difflist
);
diffopts
.
pathspec
.
count
=
0
;
if
(
0
!=
git_diff_tree_to_tree
(
&
difflist
,
blame
->
repository
,
ptree
,
otree
,
&
diffopts
))
goto
cleanup
;
...
...
@@ -439,19 +439,19 @@ static git_blame__origin* find_origin(
/* Find one that matches */
for
(
i
=
0
;
i
<
(
int
)
git_diff_num_deltas
(
difflist
);
i
++
)
{
const
git_diff_delta
*
delta
;
git_diff_get_patch
(
NULL
,
&
delta
,
difflist
,
i
);
if
(
git_vector_bsearch
(
NULL
,
&
blame
->
paths
,
delta
->
new_file
.
path
)
!=
0
)
continue
;
git_vector_insert_sorted
(
&
blame
->
paths
,
(
void
*
)
git__strdup
(
delta
->
old_file
.
path
),
paths_on_dup
);
make_origin
(
&
porigin
,
parent
,
delta
->
old_file
.
path
);
const
git_diff_delta
*
delta
=
git_diff_get_delta
(
difflist
,
i
)
;
if
(
!
git_vector_bsearch
(
NULL
,
&
blame
->
paths
,
delta
->
new_file
.
path
)
)
{
git_vector_insert_sorted
(
&
blame
->
paths
,
(
void
*
)
git__strdup
(
delta
->
old_file
.
path
),
paths_on_dup
);
make_origin
(
&
porigin
,
parent
,
delta
->
old_file
.
path
);
}
}
}
cleanup:
git_diff_
list_
free
(
difflist
);
git_diff_free
(
difflist
);
git_tree_free
(
otree
);
git_tree_free
(
ptree
);
return
porigin
;
...
...
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