diff options
author | Thomas Otto <th1000s@posteo.net> | 2021-12-22 23:30:30 +0100 |
---|---|---|
committer | Dan Davison <dandavison7@gmail.com> | 2022-01-03 17:28:27 -0500 |
commit | c1392d6e1cc8bb21dd8e59c4226f6d9154e1844e (patch) | |
tree | e1b0d5aae04611ca742e9cd168b57e953b4b2c2b | |
parent | 3a3f59770416bad40e9f4ecc6cc8b260e3a4537d (diff) |
The calling process must have a common parent with delta
Ensures that no unrelated process is found when selectively
refreshing a pid range.
-rw-r--r-- | src/utils/process.rs | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/utils/process.rs b/src/utils/process.rs index 26d68d68..cc75e31c 100644 --- a/src/utils/process.rs +++ b/src/utils/process.rs @@ -364,7 +364,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, }) @@ -849,6 +853,20 @@ pub mod tests { } #[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(&[]); assert_eq!( |