Show the diff for a specific change by hash or prefix. This displays the content introduced by the change using state-based content retrieval. For each file modified by the change, we retrieve: - The file content BEFORE the change was applied (parent state) - The file content AFTER the change was applied (current state) Then we compute a proper diff between the two states, with optional word-lev
(
&self,
repo: &Repository,
change_ref: &str,
config: &DiffOutputConfig,
)
| 31 | /// Then we compute a proper diff between the two states, with optional |
| 32 | /// word-level highlighting for code review. |
| 33 | pub(super) fn show_change_diff( |
| 34 | &self, |
| 35 | repo: &Repository, |
| 36 | change_ref: &str, |
| 37 | config: &DiffOutputConfig, |
| 38 | ) -> CliResult<()> { |
| 39 | // Resolve the change reference (full hash or prefix) |
| 40 | let hash = self.resolve_change_ref(repo, change_ref)?; |
| 41 | |
| 42 | // Load the change |
| 43 | let change = |
| 44 | repo.change_store() |
| 45 | .load_change(&hash) |
| 46 | .map_err(|_e| CliError::ChangeNotFound { |
| 47 | hash: change_ref.to_string(), |
| 48 | })?; |
| 49 | |
| 50 | // Git-imported changes carry Git's captured +/- lines in unhashed |
| 51 | // metadata. Use that directly for review output before considering |
| 52 | // FileOps or the expensive graph reconstruction fallback. Graph-first |
| 53 | // imported changes may intentionally have no FileOps yet. |
| 54 | if let Some((file_diffs, stats)) = Self::build_git_import_file_diffs(&change) { |
| 55 | return self.print_change_file_diffs(&change, &hash, config, file_diffs, stats); |
| 56 | } |
| 57 | |
| 58 | // Check if change has semantic layer (file_ops) |
| 59 | if change.has_file_ops() { |
| 60 | // Use the semantic layer for human-readable diff |
| 61 | return self.show_change_diff_from_file_ops(&change, &hash, config); |
| 62 | } |
| 63 | |
| 64 | // Fallback: compute diff from content (legacy path) |
| 65 | self.show_change_diff_computed(repo, &change, &hash, config) |
| 66 | } |
| 67 | |
| 68 | /// Show diff using the semantic layer (FileOps). |
| 69 | /// |
no test coverage detected