Skip to content

Commit

Permalink
The calling process must have a common parent with delta
Browse files Browse the repository at this point in the history
Ensures that no unrelated process is found when selectively
refreshing a pid range.
  • Loading branch information
th1000s committed Dec 23, 2021
1 parent f5e7a31 commit 4076ec4
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/utils/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,11 @@ trait ProcessInterface {
};
iter_parents(self, pid, &mut sum_distance);

Some((length_of_process_chain, args))
if length_of_process_chain == usize::MAX {
None
} else {
Some((length_of_process_chain, args))
}
}
_ => None,
})
Expand Down Expand Up @@ -847,6 +851,20 @@ pub mod tests {
calling_process_cmdline(ProcInfo::new(), guess_git_blame_filename_extension);
}

#[test]
fn test_process_blame_no_parent_found() {
let two_trees = MockProcInfo::with(&[
(2, 100, "-shell", None),
(3, 100, "git blame src/main.rs", Some(2)),
(4, 100, "call_delta.sh", None),
(5, 100, "delta", Some(4)),
]);
assert_eq!(
calling_process_cmdline(two_trees, guess_git_blame_filename_extension),
None
);
}

#[test]
fn test_process_blame_info_with_parent() {
let no_processes = MockProcInfo::with(&[]);
Expand Down

0 comments on commit 4076ec4

Please sign in to comment.