From a7d4c29785e59a490efa2b708ba10e5435e60371 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Mon, 11 May 2026 20:26:52 +0000 Subject: [PATCH] chore(git): remove dead DiffDelta::similarity and simplify parse_diff_raw MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DiffDelta::similarity() had no callers — the similarity score is parsed and stored for completeness but only accessed directly in same-module tests. Also removes stale #[allow(dead_code)] from DiffStatus, DiffFile, and DiffDelta (all actively used), and simplifies a redundant if_same_then_else branch in parse_diff_raw whose two arms were identical. Co-Authored-By: Claude Sonnet 4.6 --- src/git/diff_tree_to_tree.rs | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/src/git/diff_tree_to_tree.rs b/src/git/diff_tree_to_tree.rs index 1ce20a7673..fdc82af282 100644 --- a/src/git/diff_tree_to_tree.rs +++ b/src/git/diff_tree_to_tree.rs @@ -4,7 +4,6 @@ use crate::git::status::MAX_PATHSPEC_ARGS; use std::collections::HashSet; use std::path::{Path, PathBuf}; -#[allow(dead_code)] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum DiffStatus { Added, @@ -32,7 +31,6 @@ impl DiffStatus { } } -#[allow(dead_code)] #[derive(Debug, Clone)] pub struct DiffFile { path: Option, @@ -45,18 +43,15 @@ impl DiffFile { self.path.as_deref() } - #[allow(dead_code)] pub fn mode(&self) -> &str { &self.mode } - #[allow(dead_code)] pub fn id(&self) -> &str { &self.oid } } -#[allow(dead_code)] #[derive(Debug, Clone)] pub struct DiffDelta { status: DiffStatus, @@ -75,15 +70,9 @@ impl DiffDelta { &self.new_file } - #[allow(dead_code)] pub fn status(&self) -> DiffStatus { self.status } - - #[allow(dead_code)] - pub fn similarity(&self) -> u32 { - self.similarity - } } pub struct Diff { @@ -95,12 +84,10 @@ impl Diff { self.deltas.iter() } - #[allow(dead_code)] pub fn len(&self) -> usize { self.deltas.len() } - #[allow(dead_code)] pub fn is_empty(&self) -> bool { self.deltas.is_empty() } @@ -273,15 +260,7 @@ fn parse_diff_raw(data: &[u8]) -> Result, GitAiError> { // Construct the old_file and new_file let old_file = DiffFile { path: old_path - .or_else(|| { - // For deletions, the old file path is the path - #[allow(clippy::if_same_then_else)] - if matches!(status, DiffStatus::Deleted) { - Some(new_path.clone()) - } else { - Some(new_path.clone()) - } - }) + .or_else(|| Some(new_path.clone())) .map(PathBuf::from), mode: old_mode.to_string(), oid: old_hash.to_string(),