Skip to content

Manipulating

Creating Changes

Key: o (majutsu-new)

Open the New transient to specify options.

Direct log-buffer shortcuts:

Key: O (majutsu-new-dwim)

Create a new change on top of the revision at point (DWIM).

Key: A (majutsu-new-with-after)

Create a new change after the revision at point.

Key: B (Vanilla) (majutsu-new-with-before)

Create a new change before the revision at point.

Key: I (Evil) (majutsu-new-with-before)

Create a new change before the revision at point.

Useful transient entries include:

Key: -r

Parent revisions.

Key: -A

Insert after constraint.

Key: -B

Insert before constraint.

Key: -m

Set a message.

Key: -e

No edit (don't switch to the new change).

Runs: jj new -r REV

Describing Changes

Key: c (majutsu-describe)

Edit the description of the revision at point. Supports --ignore-immutable for immutable revisions.

Runs: jj describe -r REV

Committing

Key: C (majutsu-commit)

Run jj commit through with-editor. This edits the working-copy description, finalizes that change, and lets jj create the next empty working-copy change on top.

Runs: jj commit

Editing Changes

Key: e (majutsu-edit-changeset)

Move the working copy (@) to the revision at point. Supports --ignore-immutable for immutable revisions.

Runs: jj edit REV

Squashing

Key: s (majutsu-squash)

Open the Squash transient. You can select multiple source revisions (--from) to squash into a destination (--into).

Transient arguments:

Key: -f

Source revisions (--from).

Key: -t

Destination revision (--into).

Key: -o

Onto destination.

Key: -A / -B

Insert after or before constraints.

Key: --

Limit squash to specific filesets.

Key: -k

Keep commits that become empty after squashing.

Key: -u

Use the destination revision's description and discard source descriptions (--use-destination-message).

Runs: jj squash --from SRC --into DEST [FILESETS...]

Absorbing

Key: a (majutsu-absorb)

Open the Absorb transient.

Transient arguments:

Key: -f

Source revision (--from, default @).

Key: -t

Destination revset filters (--into, repeatable, default mutable()).

Key: --

Limit absorb to specific filesets.

Runs: jj absorb --from REV --into REVSETS... [FILESETS...]

Rebasing

Key: r (majutsu-rebase)

Open the Rebase transient. This is one of Majutsu's most powerful features, allowing you to visually select sources and destinations.

Transient arguments:

Key: -s

Rebase a revision and its descendants (--source).

Key: -b

Rebase a whole branch relative to the destination (--branch).

Key: -r

Rebase only the selected revisions while preserving dependencies among them (--revision).

Key: -o

Rebase onto destination parent(s) (--onto).

Key: -A / -B

Insert after or before the selected destination revisions.

Key: -p

Remove redundant parent edges while rebasing (--simplify-parents).

Exactly one source style (-s, -b, or -r) and one destination style (-o, -A, or -B) may be active. The destination is required before Majutsu executes the command. Runs: jj rebase --source SRC --onto DEST

Duplicating

Key: ? y (majutsu-duplicate)

Open the Duplicate transient. Allows selecting source revisions and destination.

Transient arguments:

Key: -r

Source revisions to duplicate.

Key: -o

Destination (--onto).

Key: -A / -B

Insert after or before constraints.

Runs: jj duplicate -r REV

Abandoning

Key: k (Vanilla) (majutsu-abandon)

Remove the revision at point from visible history and rebase its descendants onto its parent(s). With an active region selection, Majutsu abandons all selected revisions. The operation remains recoverable through jj's operation history until that history is pruned.

Key: x (Evil) (majutsu-abandon)

Remove the revision at point from visible history and rebase its descendants onto its parent(s). With an active region selection, Majutsu abandons all selected revisions. The operation remains recoverable through jj's operation history until that history is pruned.

Runs: jj abandon REV

Undo and Redo

Key: C-/ / C-? (Vanilla) (majutsu-undo / majutsu-redo)

Undo or redo.

Key: u / C-r (Evil) (majutsu-undo / majutsu-redo)

Undo or redo.

Runs: jj undo or jj redo

Splitting

Key: S (majutsu-split)

Open the Split transient. This allows you to split a revision into multiple parts.

Transient arguments:

Key: -r

Specify the revision to split.

Key: -o

Specify the destination (--onto).

Key: -A / -B

Insert after or before constraints.

Key: -m

Set a message for the first part.

Key: -p

Parallel split mode.

Key: --

Limit split to selected files or filesets.

Runs: jj split -r REV [FILESETS...]

Restoring

Key: R (majutsu-restore)

Open the Restore transient for undoing changes.

Transient arguments:

Key: -f

Restore from a specific revision (--from).

Key: -t

Restore to a specific revision (--to).

Key: -c

Undo changes introduced by a revision (--changes-in).

Key: -d

Restore descendants as well.

Key: --

Limit restore to selected files or filesets.

Runs: jj restore --from REV [FILESETS...] or jj restore --changes-in REV [FILESETS...]

Reverting

Key: V (Vanilla) (majutsu-revert)

Open the Revert transient to apply reverse changes in one or more new revisions.

Key: _ (Evil) (majutsu-revert)

Open the Revert transient to apply reverse changes in one or more new revisions.

Transient arguments:

Key: -r

Source revisions to revert (--revision, repeatable).

Key: -o

Apply reverse changes on top of revisions (--onto).

Key: -A / -B

Insert reverse changes after or before selected revisions.

Runs: jj revert --revision REV --onto DEST

Sparse Working Copy

Key: > (majutsu-sparse)

Open the sparse working copy transient (set, add, remove, list, edit).

Sparse transient actions:

Key: l (majutsu-sparse-list)

List current sparse patterns in *Majutsu Sparse*.

Key: s / S (majutsu-sparse-set / majutsu-sparse-set-clear)

Set patterns by appending, or replace the entire set after clearing it first.

Key: a / r (majutsu-sparse-add / majutsu-sparse-remove)

Add or remove patterns incrementally.

Key: e (majutsu-sparse-edit)

Edit patterns via jj sparse edit.

Key: R (majutsu-sparse-reset)

Reset to all files (jj sparse reset).

Notes:

  • Editing patterns opens a temporary .jjsparse buffer.

  • Lines starting with JJ: are comments and are ignored by Jujutsu.

  • Pattern completion includes current directories/files from @.

  • Default "all files" state is represented by single pattern ..

Interactive Patching

Majutsu provides transient-scoped partial patch selection for Jujutsu operations. This allows you to select specific hunks, files, or even regions within hunks to include in Split, Squash, or Restore operations. The selection overlays belong to the current transient session and are cleared when that session ends; they are not a persistent staging area.

How It Works

Interactive selection is integrated into the Split (S), Squash (s), and Restore (R) transients. When you open one of these transients from a Diff buffer, a "Patch Selection" group appears with the following commands:

KeyCommandDescription
Hmajutsu-interactive-toggle-hunkToggle selection of hunk at point
Fmajutsu-interactive-toggle-fileToggle all file hunks or a whole-file change with no text hunks
Rmajutsu-interactive-toggle-regionToggle selection of active region
Cmajutsu-interactive-clearClear all patch selections

The -i argument is a separate, jj-native workflow. When no H/F/R patch selection is active, Majutsu forwards --interactive (and Split/Squash's --tool argument) to jj; --interactive therefore uses the user's configured ui.diff-editor. Majutsu does not silently replace that editor with Ediff. The H/F/R workflow instead supplies Majutsu's own temporary patch tool when the operation is executed.

Diff Context Inheritance

When opening Split, Squash, or Restore from a Diff buffer, each transient maps the compatible part of the diff context to its own command:

  • Split converts a single --revisions source to --revision.

  • Squash converts --revisions sources to repeatable --from arguments.

  • Restore converts --revisions to --changes-in and also inherits explicit --from / --to ranges.

Use a revision diff for Split or Squash. An arbitrary --from / --to range is meaningful as inherited context only for Restore.

This means you can:

  1. View a diff with specific --from / --to revisions

  2. Open the Restore transient

  3. Select specific hunks to restore

  4. The restore will apply only to those hunks, using the diff's revision context

Visual Feedback

Selected hunks are highlighted with the majutsu-interactive-selected-hunk face (green background by default). Selected regions within hunks use the majutsu-interactive-selected-region face (purple background). Selected file changes with no text hunks use the majutsu-interactive-selected-file face.

Selection Semantics

The meaning of "selected" differs by operation:

Split and Squash

For Split and Squash, selected content is what gets moved:

  • Split: Selected hunks/regions go into the first commit; unselected content stays in the second commit.

  • Squash: Selected hunks/regions move into the chosen destination; by default Majutsu infers the source revision's external parent. Unselected content remains in the source revision.

Example: You have a revision with changes to files A, B, and C. You want to squash only the changes to file A into the parent:

  1. Open the diff for the revision (D)

  2. Open Squash transient (s)

  3. Press F on file A to select all its hunks

  4. Execute squash - file A's changes go to parent, B and C stay

Restore

For Restore, selected content is what gets restored (undone):

  • Selected hunks/regions are reverted to their state in the source revision

  • Unselected content is left unchanged

Technical Implementation

Majutsu uses a custom merge tool to apply partial patches. When you execute an operation with selections:

  1. Patch Generation: Majutsu generates a unified diff patch containing only the selected hunks/regions.

    For Restore, it instead builds complementary replay data: the unselected hunks and whole-file changes. Hunkless whole-file changes are represented by structured jj metadata rather than inferred from rendered Git headers.

  2. Tool Invocation: Jujutsu's -i --tool mechanism is used with a custom majutsu-applypatch tool.

    Each operation stores its patch file and helper script in a separate temporary directory, so overlapping asynchronous operations do not share input files.

  3. Patch Application:

    • For Split/Squash: The tool resets $right (current state) to $left (parent state), then applies the patch forward. This results in $right containing only the selected changes.

      • For Restore: $right starts at the source state. The tool applies the complementary text patch and whole-file changes forward, reconstructing the result with the selected changes restored to their source state.

This approach avoids the complexity of reverse patch application (git apply -R), which has edge cases with new files, deleted files, and content starting with + or -.

Edge Cases

Text-hunk selection supports the file operations below. Hunkless whole-file selection is available for all three operations as described at the end of this section.

New Files

When splitting or squashing a new file:

  • If you select the entire file, it goes to the first commit / gets squashed

  • If you select only part of the file, only those lines go; the rest stays

For Restore, selected lines are restored to the source state and unselected lines are retained. This also covers a selected portion of a newly added file without reverse-applying a new-file patch.

Deleted Files

Note: Partial text selection for deleted files is currently limited.

Select the entire deletion or none. This limitation is independent of hunkless whole-file selection, which handles file changes that have no text hunks.

Renamed/Copied Files

Renamed and copied files are handled correctly:

  • Text-hunk patches preserve rename/copy information

  • You can select specific hunks within renamed files just like regular modifications

Changes Without Text Hunks

In a Git-format diff buffer, Split, Squash, and Restore can select a file change with no text hunks, such as a binary or mode-only change, as a unit. Majutsu uses structured metadata from jj as the source of the file operation and paths, and verifies it against the displayed file headers. If the selection cannot be verified, Majutsu refuses it. Restore replays the complementary whole-file changes, so the selected file change is restored as a unit.

Workflow Example

  1. Open a diff with D or d

  2. Open Split (S), Squash (s), or Restore (R) transient

  3. Use H to select individual hunks, or F to select all hunks in a file

  4. For fine-grained control, mark a region and press R to select only those lines

  5. Press C to clear selections if needed

  6. Execute the operation - only selected changes will be affected

Customization

Face: majutsu-interactive-selected-hunk

Face for selected hunks.

Face: majutsu-interactive-selected-region

Face for selected regions.

Face: majutsu-interactive-selected-file

Face for selected file changes with no text hunks.

Metaediting

Key: ? m (majutsu-metaedit)

Open the Metaedit transient. Revisions in the active region are selected initially, followed by the revision at point, then @ as fallbacks.

Transient arguments:

Key: r / -r / c

Toggle revisions at point or in the active region, read a revset, or clear the visual revision selections. Multiple revisions are supported.

Key: -m / -a / -t

Set message, author, and author timestamp.

Key: -c / -u / -U / -f

Toggle update-change-id, update-author, update-author-timestamp, or force-rewrite.

Key: -I

Ignore immutable revisions.

Runs: jj metaedit [OPTIONS...] [REVSETS]...

Signing and Unsigning

Key: ? j (majutsu-sign)

Open the Sign transient. Revisions in the active region are selected initially, followed by the revision at point, then @ as fallbacks.

Key: ? J (majutsu-unsign)

Open the Unsign transient with the same visual revision selection.

Transient arguments:

Key: r / -r / c

Toggle revisions at point or in the active region, read a revset, or clear the visual revision selections.

Key: -k

Override the configured signing key for jj sign. Majutsu completes secret signing keys for the gpg and gpgsm backends, and the configured key plus ~/.ssh/*.pub for the ssh backend. Arbitrary values remain available for backend-specific key formats. A commit-signing backend must be configured in jj.

Key: -I

Ignore immutable revisions.

Runs: jj sign --revision REVSETS... or jj unsign --revision REVSETS...

Simplifying Parents

Key: ? P (majutsu-simplify-parents)

Open the Simplify Parents transient.

Transient arguments:

Key: -s

Simplify specified revision(s) together with descendant trees (--source).

Key: -r

Simplify specified revision(s) only (--revision).

Key: -I

Ignore immutable revisions.

If neither --source nor --revision is set, the Simplify action defaults to selected region revisions, then the revision at point, then @. Runs: jj simplify-parents [--source REVSET] [--revision REVSET]