Skip to content

Commit 8a298bf

Browse files
docs: Add ASCII graphs to interdiff, squash, and duplicate help
This addresses #3687 by adding visual ASCII diagrams to the help text of commands that work with commit graphs: - interdiff: Shows how commits are compared by rebasing - squash: Shows how changes are moved between commits - duplicate: Shows how commits are copied onto their parents or new destinations Added #[command(verbatim_doc_comment)] to preserve the ASCII art formatting. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
1 parent eb64739 commit 8a298bf

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

cli/src/commands/duplicate.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,35 @@ use crate::ui::Ui;
4141
/// are provided, commits will be duplicated onto their existing parents or onto
4242
/// other newly duplicated commits.
4343
///
44+
/// ```text
45+
/// C C C'
46+
/// | => | /
47+
/// B B
48+
/// ```
49+
/// (C is duplicated to C', both have the same parent B)
50+
///
4451
/// When any of the `--onto`, `--insert-after`, or `--insert-before` arguments
4552
/// are provided, the roots of the specified commits will be duplicated onto the
4653
/// destination indicated by the arguments. Other specified commits will be
4754
/// duplicated onto these newly duplicated commits. If the `--insert-after` or
4855
/// `--insert-before` arguments are provided, the new children indicated by the
4956
/// arguments will be rebased onto the heads of the specified commits.
5057
///
58+
/// ```text
59+
/// C C'
60+
/// | |
61+
/// B => D
62+
/// | |
63+
/// A D B C
64+
/// \ \ /
65+
/// E A E
66+
/// ```
67+
/// (duplicating C onto D with `jj duplicate C --onto D`)
68+
///
5169
/// By default, the duplicated commits retain the descriptions of the originals.
5270
/// This can be customized with the `templates.duplicate_description` setting.
5371
#[derive(clap::Args, Clone, Debug)]
72+
#[command(verbatim_doc_comment)]
5473
pub(crate) struct DuplicateArgs {
5574
/// The revision(s) to duplicate (default: @)
5675
#[arg(

cli/src/commands/interdiff.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,25 @@ use crate::ui::Ui;
3232
/// This excludes changes from other commits by temporarily rebasing `--from`
3333
/// onto `--to`'s parents. If you wish to compare the same change across
3434
/// versions, consider `jj evolog -p` instead.
35+
///
36+
/// For example, with `jj interdiff --from A --to C`:
37+
///
38+
/// ```text
39+
/// D
40+
/// |
41+
/// C C
42+
/// | |
43+
/// B A' (A rebased onto C's parent)
44+
/// | |
45+
/// A B
46+
/// \ /
47+
/// root
48+
/// ```
49+
///
50+
/// The command compares A' (A rebased onto B) with C, effectively showing
51+
/// what changed between the two commits independent of their different bases.
3552
#[derive(clap::Args, Clone, Debug)]
53+
#[command(verbatim_doc_comment)]
3654
#[command(group(ArgGroup::new("to_diff").args(&["from", "to"]).multiple(true).required(true)))]
3755
#[command(mut_arg("ignore_all_space", |a| a.short('w')))]
3856
#[command(mut_arg("ignore_space_change", |a| a.short('b')))]

cli/src/commands/squash.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@ use crate::ui::Ui;
5555
/// parent revision. Fails if there are several parent revisions (i.e., the
5656
/// given revision is a merge).
5757
///
58+
/// ```text
59+
/// D D
60+
/// | |
61+
/// C => B' (contains changes from both B and C; C is abandoned)
62+
/// | |
63+
/// B A
64+
/// |
65+
/// A
66+
/// ```
67+
///
5868
/// With the `--from` and/or `--into` options, moves changes from/to the given
5969
/// revisions. If either is left out, it defaults to the working-copy commit.
6070
/// For example, `jj squash --into @--` moves changes from the working-copy
@@ -78,6 +88,7 @@ use crate::ui::Ui;
7888
/// together with one or more `--from` options (if no `--from` is specified,
7989
/// `--from @` is assumed).
8090
#[derive(clap::Args, Clone, Debug)]
91+
#[command(verbatim_doc_comment)]
8192
pub(crate) struct SquashArgs {
8293
/// Revision to squash into its parent (default: @). Incompatible with the
8394
/// experimental `-o`/`-A`/`-B` options.

0 commit comments

Comments
 (0)