Render a computed diff in the requested format. `--json` wins over every text format selector, so a consumer gets a single parseable document rather than a rendered diff it has to re-parse. `change` is `Some` for `atomic diff -c `; `view` is populated only for working-copy diffs.
(
&self,
file_diffs: &[FileDiff],
stats: &DiffStats,
config: &DiffOutputConfig,
change: Option<(&Change, &Hash)>,
view: Option<&str>,
)
| 77 | /// re-parse. `change` is `Some` for `atomic diff -c <hash>`; `view` is |
| 78 | /// populated only for working-copy diffs. |
| 79 | pub(crate) fn render( |
| 80 | &self, |
| 81 | file_diffs: &[FileDiff], |
| 82 | stats: &DiffStats, |
| 83 | config: &DiffOutputConfig, |
| 84 | change: Option<(&Change, &Hash)>, |
| 85 | view: Option<&str>, |
| 86 | ) -> CliResult<()> { |
| 87 | if self.json { |
| 88 | return json::print_json(&json::JsonDiff::new(file_diffs, stats, change, view)); |
| 89 | } |
| 90 | |
| 91 | match config.format { |
| 92 | DiffFormat::Unified => self.print_unified(file_diffs, config), |
| 93 | DiffFormat::Stat => self.print_stat(stats, config), |
| 94 | DiffFormat::NameOnly => self.print_name_only(file_diffs), |
| 95 | DiffFormat::NameStatus => self.print_name_status(file_diffs, config), |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | /// Print a message when there are no changes. |
| 100 | pub(super) fn print_no_changes(&self) { |
no test coverage detected