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
bba9599a
Unverified
Commit
bba9599a
authored
Mar 26, 2020
by
Edward Thomson
Committed by
GitHub
Mar 26, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5445 from lhchavez/fix-5443
Fix segfault when calling git_blame_buffer()
parents
9d5016dc
62d59467
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
34 additions
and
2 deletions
+34
-2
src/blame.c
+1
-1
tests/blame/buffer.c
+26
-0
tests/resources/blametest.git/objects/83/6bc00b06cb60eb0f629e237ad2b58adb2cfc7e
+4
-0
tests/resources/blametest.git/objects/a8/ba8436b5d8ccbdfd5be597c194e7bb8e0a092f
+2
-0
tests/resources/blametest.git/objects/f9/264f7fbd31ae7a18b7931ed8946fb0aebb0af3
+0
-0
tests/resources/blametest.git/refs/heads/master
+1
-1
No files found.
src/blame.c
View file @
bba9599a
...
...
@@ -415,7 +415,7 @@ on_error:
static
bool
hunk_is_bufferblame
(
git_blame_hunk
*
hunk
)
{
return
git_oid_is_zero
(
&
hunk
->
final_commit_id
);
return
hunk
&&
git_oid_is_zero
(
&
hunk
->
final_commit_id
);
}
static
int
buffer_hunk_cb
(
...
...
tests/blame/buffer.c
View file @
bba9599a
...
...
@@ -17,6 +17,32 @@ void test_blame_buffer__cleanup(void)
git_repository_free
(
g_repo
);
}
void
test_blame_buffer__index
(
void
)
{
const
git_blame_hunk
*
hunk
;
const
char
*
buffer
=
"Hello
\n
World!"
;
/*
* We need to open a different file from the ones used in other tests. Close
* the one opened in test_blame_buffer__initialize() to avoid a leak.
*/
git_blame_free
(
g_fileblame
);
g_fileblame
=
NULL
;
cl_git_pass
(
git_blame_file
(
&
g_fileblame
,
g_repo
,
"file.txt"
,
NULL
));
cl_git_pass
(
git_blame_buffer
(
&
g_bufferblame
,
g_fileblame
,
buffer
,
strlen
(
buffer
)));
cl_assert_equal_i
(
2
,
git_blame_get_hunk_count
(
g_bufferblame
));
check_blame_hunk_index
(
g_repo
,
g_bufferblame
,
0
,
1
,
1
,
0
,
"836bc00b"
,
"file.txt"
);
hunk
=
git_blame_get_hunk_byline
(
g_bufferblame
,
1
);
cl_assert
(
hunk
);
cl_assert_equal_s
(
"lhchavez"
,
hunk
->
final_signature
->
name
);
check_blame_hunk_index
(
g_repo
,
g_bufferblame
,
1
,
2
,
1
,
0
,
"00000000"
,
"file.txt"
);
hunk
=
git_blame_get_hunk_byline
(
g_bufferblame
,
2
);
cl_assert
(
hunk
);
cl_assert
(
hunk
->
final_signature
==
NULL
);
}
void
test_blame_buffer__added_line
(
void
)
{
const
git_blame_hunk
*
hunk
;
...
...
tests/resources/blametest.git/objects/83/6bc00b06cb60eb0f629e237ad2b58adb2cfc7e
0 → 100644
View file @
bba9599a
File added
tests/resources/blametest.git/objects/a8/ba8436b5d8ccbdfd5be597c194e7bb8e0a092f
0 → 100644
View file @
bba9599a
File added
tests/resources/blametest.git/objects/f9/264f7fbd31ae7a18b7931ed8946fb0aebb0af3
0 → 100644
View file @
bba9599a
File added
tests/resources/blametest.git/refs/heads/master
View file @
bba9599a
6653ff42313eb5c82806f145391b18a9699800c7
836bc00b06cb60eb0f629e237ad2b58adb2cfc7e
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