zed/crates/cli
David Barsky 185a80a21b
cli: Teach --diff to recurse into directories and add a MultiDiffView (#45131)
This branch:
1. teaches `--diff `command line option to to recurse into folders if
provided.
2. Adds a `MultiDiffView` that shows _all_ changed files in a single,
scrollable view.

This is necessary to provide a smooth user experience for `jj` and Zed
users who wish to use Zed as their jj difftool.

I'm not fully sure how this change interacts with
https://github.com/zed-industries/zed/pull/44936, or what plans y'all
have in mind.

Here's a screenshot of the resulting behavior:

<img width="1090" height="950" alt="Screenshot 2025-12-17 at 9 10 52 AM"
src="https://github.com/user-attachments/assets/8efd09b4-974f-4059-9f94-539c484c6d4a"
/>

I setup zed to handle jj diffs by adding the following to my jj config:

```toml
[aliases]
zdiff = ["diff", "--tool", "zed"]

[merge-tools.zed]
program = "/Users/dbarsky/Developer/zed/target/debug/cli"
# omit diff-invocation-mode to keep the default (JJ passes two dirs)
diff-args = [
  "--zed", "/Users/dbarsky/Developer/zed/target/debug/zed",
  "--wait",
  "--new",
  "--diff",
  "$left",
  "$right",
]
```

Release Notes:

- `--diff`, if provided with folders instead of files, will recurse into
those directories.
- Added a `MultiDiffView`, which will show all changed files within a
single, scrollable view.

**AI Disclosure**: Pretty much all of this code was written using Codex
with GPT-5.1-Codex. I edited by hand and tested this.

---------

Co-authored-by: Lukas Wirth <lukas@zed.dev>
2026-01-30 10:14:36 +01:00
..
src cli: Teach --diff to recurse into directories and add a MultiDiffView (#45131) 2026-01-30 10:14:36 +01:00
build.rs releases: Add build number to Nightly builds (#42990) 2025-11-24 13:34:04 +01:00
Cargo.toml cli: Teach --diff to recurse into directories and add a MultiDiffView (#45131) 2026-01-30 10:14:36 +01:00
LICENSE-GPL chore: Change AGPL-licensed crates to GPL (except for collab) (#4231) 2024-01-24 00:26:58 +01:00
README.md remote: Support line and column numbers for remote paths (#40410) 2025-10-17 10:50:22 +00:00

Cli

Testing

You can test your changes to the cli crate by first building the main zed binary:

cargo build -p zed

And then building and running the cli crate with the following parameters:

 cargo run -p cli -- --zed ./target/debug/zed.exe