1use crate::graph::GitGraph;
4use std::cmp::max;
5
6pub mod colors;
7pub mod format;
8pub mod svg;
9pub mod unicode;
10
11fn get_deviate_index(graph: &GitGraph, index: usize, par_index: usize) -> usize {
16 let info = &graph.commits[index];
17
18 let par_info = &graph.commits[par_index];
19 let par_branch = &graph.all_branches[par_info.branch_trace.unwrap()];
20
21 let mut min_split_idx = index;
22 for sibling_oid in &par_info.children {
23 if let Some(&sibling_index) = graph.indices.get(sibling_oid) {
24 if let Some(sibling) = graph.commits.get(sibling_index) {
25 if let Some(sibling_trace) = sibling.branch_trace {
26 let sibling_branch = &graph.all_branches[sibling_trace];
27 if sibling_oid != &info.oid
28 && sibling_branch.visual.column == par_branch.visual.column
29 && sibling_index > min_split_idx
30 {
31 min_split_idx = sibling_index;
32 }
33 }
34 }
35 }
36 }
37
38 if info.is_merge {
41 max(index, min_split_idx)
42 } else {
43 (par_index as i32 - 1) as usize
44 }
45}