Skip to content

Commit 5d748af

Browse files
committed
Only add entry when blame was passed
1 parent 952c577 commit 5d748af

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

gix-blame/src/file/function.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -329,17 +329,21 @@ pub fn file(
329329
options.diff_algorithm,
330330
&mut stats,
331331
)?;
332-
hunks_to_blame = process_changes(hunks_to_blame, changes, suspect, *parent_id);
332+
hunks_to_blame = process_changes(hunks_to_blame, changes.clone(), suspect, *parent_id);
333333
if let Some(ref mut blame_path) = blame_path {
334-
let blame_path_entry = BlamePathEntry {
335-
source_file_path: current_file_path.clone(),
336-
previous_source_file_path: Some(current_file_path.clone()),
337-
commit_id: suspect,
338-
blob_id: id,
339-
previous_blob_id: previous_id,
340-
index,
341-
};
342-
blame_path.push(blame_path_entry);
334+
let has_blame_been_passed = hunks_to_blame.iter().any(|hunk| hunk.has_suspect(parent_id));
335+
336+
if has_blame_been_passed {
337+
let blame_path_entry = BlamePathEntry {
338+
source_file_path: current_file_path.clone(),
339+
previous_source_file_path: Some(current_file_path.clone()),
340+
commit_id: suspect,
341+
blob_id: id,
342+
previous_blob_id: previous_id,
343+
index,
344+
};
345+
blame_path.push(blame_path_entry);
346+
}
343347
}
344348
}
345349
TreeDiffChange::Rewrite {

0 commit comments

Comments
 (0)