(
header: ChangeHeader,
parsed: &ParsedCommit,
line_index: &ImportLineIndex,
graph_only: bool,
)
| 1086 | } |
| 1087 | |
| 1088 | fn build_graph_first_change( |
| 1089 | header: ChangeHeader, |
| 1090 | parsed: &ParsedCommit, |
| 1091 | line_index: &ImportLineIndex, |
| 1092 | graph_only: bool, |
| 1093 | ) -> Result<(Change, Vec<PendingLineIndexUpdate>, Vec<String>), Vec<GraphFirstSkip>> { |
| 1094 | if parsed.files.is_empty() { |
| 1095 | return Err(vec![GraphFirstSkip { |
| 1096 | path: String::new(), |
| 1097 | operation: FileOperation::Modified, |
| 1098 | reason: "empty_commit", |
| 1099 | }]); |
| 1100 | } |
| 1101 | |
| 1102 | let mut contents = Vec::new(); |
| 1103 | let mut hunks = Vec::new(); |
| 1104 | let mut file_ops = Vec::new(); |
| 1105 | let mut next_file_idx = 0u32; |
| 1106 | let mut next_branch_idx = 0u32; |
| 1107 | let mut dependencies = HashSet::new(); |
| 1108 | let mut pending = Vec::new(); |
| 1109 | let mut deleted_paths = Vec::new(); |
| 1110 | let mut skips = Vec::new(); |
| 1111 | |
| 1112 | for file in &parsed.files { |
| 1113 | match file.operation { |
| 1114 | FileOperation::Added | FileOperation::Copied => { |
| 1115 | let new_content = file.new_content.as_deref().unwrap_or(&[]); |
| 1116 | let encoding = Encoding::detect(new_content); |
| 1117 | |
| 1118 | let filename = extract_filename(&file.path); |
| 1119 | let name_start = ChangePosition::new(contents.len() as u64); |
| 1120 | contents.extend_from_slice(filename.as_bytes()); |
| 1121 | let name_end = ChangePosition::new(contents.len() as u64); |
| 1122 | let inode_pos = Position { |
| 1123 | change: None, |
| 1124 | pos: name_end, |
| 1125 | }; |
| 1126 | let name_pos = Position { |
| 1127 | change: None, |
| 1128 | pos: name_end, |
| 1129 | }; |
| 1130 | let parent_pos = Position { |
| 1131 | change: Some(ContentHash::NONE), |
| 1132 | pos: ChangePosition::ROOT, |
| 1133 | }; |
| 1134 | |
| 1135 | let new_line_contents: Vec<Vec<u8>> = |
| 1136 | if encoding == Encoding::Binary || is_generated_diff_skip_path(&file.path) { |
| 1137 | if new_content.is_empty() { |
| 1138 | Vec::new() |
| 1139 | } else { |
| 1140 | vec![new_content.to_vec()] |
| 1141 | } |
| 1142 | } else { |
| 1143 | split_graph_first_lines(new_content) |
| 1144 | .into_iter() |
| 1145 | .map(|line| line.to_vec()) |
no test coverage detected