summaryrefslogtreecommitdiff
path: root/src/blame.c
diff options
context:
space:
mode:
authorBen Straub <bs@github.com>2013-11-12 18:57:16 -0800
committerBen Straub <bs@github.com>2013-11-12 18:57:16 -0800
commit9db56cc4a78ee7799450cd3838af12124ccc4e8e (patch)
treee9918c0ab9487d7f247e3ace59569777acf418ac /src/blame.c
parent089297b2cd4f50a2218130f9f3a0ddceb86b8697 (diff)
downloadlibgit2-9db56cc4a78ee7799450cd3838af12124ccc4e8e.tar.gz
Fix buffer blame with new lines at end of file
Diffstat (limited to 'src/blame.c')
-rw-r--r--src/blame.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/blame.c b/src/blame.c
index b562b5b98..c5b7083ad 100644
--- a/src/blame.c
+++ b/src/blame.c
@@ -386,9 +386,13 @@ static int buffer_hunk_cb(
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 */
blame->current_hunk = (git_blame_hunk*)git_blame_get_hunk_byline(blame, wedge_line);
- if (!hunk_starts_at_or_after_line(blame->current_hunk, wedge_line)){
+ if (!blame->current_hunk) {
+ /* Line added at the end of the file */
+ blame->current_hunk = new_hunk(wedge_line, 0, wedge_line, blame->path);
+ git_vector_insert(&blame->hunks, blame->current_hunk);
+ } else if (!hunk_starts_at_or_after_line(blame->current_hunk, wedge_line)){
+ /* If this hunk doesn't start between existing hunks, split a hunk up so it does */
blame->current_hunk = split_hunk_in_vector(&blame->hunks, blame->current_hunk,
wedge_line - blame->current_hunk->orig_start_line_number, true);
}
@@ -409,13 +413,6 @@ static int buffer_line_cb(
GIT_UNUSED(hunk);
GIT_UNUSED(line);
-#ifdef DO_DEBUG
- {
- char *str = git__substrdup(content, content_len);
- git__free(str);
- }
-#endif
-
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)) {