In short: it reads both files, wraps each as a resolved one-sided Merge, and passes them to the same
show_diff_bytes the repo diff commands use for file content. Only the Git and color-words formats print
anything; the summary-style formats are hidden, and an external --tool prints nothing yet.
The command is cmd_util_diff. Its help text: "Compare two files on
disk" (source). It is the Diff variant of UtilCommand
(source, dispatch).
1. Command-line surface
| Argument | Type | Default | Meaning |
|---|---|---|---|
PATH1, PATH2 (positional, required) | paths | none | "First path to compare", "Second path to compare" (source). |
| Diff format flags | flags | ui.diff-formatter | The shared DiffFormatArgs, such as --git, --color-words and --tool. --summary, --stat, --types and --name-only are hidden, and -w/-b are added as short forms of --ignore-all-space/--ignore-space-change (source). |
Format flags and defaults are covered on the jj diff page.
The global flags are on the CLI page.
3. End-to-end flow
4. Core architecture touchpoints
| Piece | Role here |
|---|---|
diff_util::show_diff_bytes | Renders two byte contents with the chosen formats. Short formats are skipped because "printing dummy file path wouldn't be useful"; DiffFormat::Tool has a TODO and prints nothing (source, source). |
Merge | Each file is a resolved one-term merge, so the renderers that also handle conflicted files can be reused (source). Merges are covered on the conflicts page. |
| Repo, working copy, operation log | Not touched: the command never asks for a workspace. Identical files print nothing; different ones print a normal Git or color-words diff (test). |