(
header: ChangeHeader,
parsed: &ParsedCommit,
line_index: &ImportLineIndex,
graph_only: bool,
)
| 1155 | } |
| 1156 | |
| 1157 | fn build_graph_first_change( |
| 1158 | header: ChangeHeader, |
| 1159 | parsed: &ParsedCommit, |
| 1160 | line_index: &ImportLineIndex, |
| 1161 | graph_only: bool, |
| 1162 | ) -> Result<(Change, Vec<PendingLineIndexUpdate>, Vec<String>), Vec<GraphFirstSkip>> { |
| 1163 | if parsed.files.is_empty() { |
| 1164 | return Err(vec![GraphFirstSkip { |
| 1165 | path: String::new(), |
| 1166 | operation: FileOperation::Modified, |
| 1167 | reason: "empty_commit", |
| 1168 | }]); |
| 1169 | } |
| 1170 | |
| 1171 | let mut contents = Vec::new(); |
| 1172 | let mut hunks = Vec::new(); |
| 1173 | let mut file_ops = Vec::new(); |
| 1174 | let mut next_file_idx = 0u32; |
| 1175 | let mut next_branch_idx = 0u32; |
| 1176 | let mut dependencies = HashSet::new(); |
| 1177 | let mut pending = Vec::new(); |
| 1178 | let mut deleted_paths = Vec::new(); |
| 1179 | let mut skips = Vec::new(); |
| 1180 | |
| 1181 | for file in &parsed.files { |
| 1182 | match file.operation { |
| 1183 | FileOperation::Added | FileOperation::Copied => { |
| 1184 | let new_content = file.new_content.as_deref().unwrap_or(&[]); |
| 1185 | let encoding = Encoding::detect(new_content); |
| 1186 | |
| 1187 | let filename = extract_filename(&file.path); |
| 1188 | let name_start = ChangePosition::new(contents.len() as u64); |
| 1189 | contents.extend_from_slice(filename.as_bytes()); |
| 1190 | let name_end = ChangePosition::new(contents.len() as u64); |
| 1191 | let inode_pos = Position { |
| 1192 | change: None, |
| 1193 | pos: name_end, |
| 1194 | }; |
| 1195 | let name_pos = Position { |
| 1196 | change: None, |
| 1197 | pos: name_end, |
| 1198 | }; |
| 1199 | let parent_pos = Position { |
| 1200 | change: Some(ContentHash::NONE), |
| 1201 | pos: ChangePosition::ROOT, |
| 1202 | }; |
| 1203 | |
| 1204 | let new_line_contents: Vec<Vec<u8>> = |
| 1205 | if encoding == Encoding::Binary || is_generated_diff_skip_path(&file.path) { |
| 1206 | if new_content.is_empty() { |
| 1207 | Vec::new() |
| 1208 | } else { |
| 1209 | vec![new_content.to_vec()] |
| 1210 | } |
| 1211 | } else { |
| 1212 | split_graph_first_lines(new_content) |
| 1213 | .into_iter() |
| 1214 | .map(|line| line.to_vec()) |
no test coverage detected