======================== CODE SNIPPETS ======================== TITLE: Install jj on Windows using winget DESCRIPTION: Installs the latest release of jj on Windows using the winget package manager. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/install-and-setup.md#_snippet_10 LANGUAGE: powershell CODE: ``` winget install jj-vcs.jj ``` ---------------------------------------- TITLE: Install jj on Gentoo Linux DESCRIPTION: Installs jj on Gentoo Linux by enabling the GURU repository and then using Portage to install the dev-vcs/jj package. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/install-and-setup.md#_snippet_7 LANGUAGE: shell CODE: ``` emerge -av dev-vcs/jj ``` ---------------------------------------- TITLE: Install jj from source (prerelease) DESCRIPTION: Installs the prerelease version of jj from the main branch of its Git repository. Requires Rust version >= 1.85 and the build-essential package. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/install-and-setup.md#_snippet_1 LANGUAGE: shell CODE: ``` sudo apt-get install build-essential # To install the *prerelease* version from the main branch cargo install --git https://github.com/jj-vcs/jj.git --locked --bin jj jj-cli ``` ---------------------------------------- TITLE: Install jj using NixOS profile (prerelease) DESCRIPTION: Installs the prerelease version of jj from its Git repository flake into the user's Nix profile on NixOS. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/install-and-setup.md#_snippet_5 LANGUAGE: shell CODE: ``` # Installs the prerelease version from the main branch nix profile install 'github:jj-vcs/jj' ``` ---------------------------------------- TITLE: Install jj using cargo-binstall DESCRIPTION: Installs the latest jj release binary from GitHub using cargo-binstall. This command places the jj binary in the default ~/.cargo/bin directory. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/install-and-setup.md#_snippet_0 LANGUAGE: shell CODE: ``` cargo binstall --strategies crate-meta-data jj-cli ``` ---------------------------------------- TITLE: Install jj on Windows using scoop DESCRIPTION: Installs the latest release of jj on Windows using the scoop package manager. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/install-and-setup.md#_snippet_11 LANGUAGE: shell CODE: ``` scoop install main/jj ``` ---------------------------------------- TITLE: Install jj using Homebrew DESCRIPTION: Installs the latest release of jj on macOS and Linux systems that use Homebrew. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/install-and-setup.md#_snippet_6 LANGUAGE: shell CODE: ``` brew install jj ``` ---------------------------------------- TITLE: Nushell Standard Completions DESCRIPTION: Installs standard command-line completions for jj in Nushell. This involves saving the completion script to a file and then sourcing it within the Nushell environment. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/install-and-setup.md#_snippet_16 LANGUAGE: nu CODE: ``` jj util completion nushell | save completions-jj.nu use completions-jj.nu * ``` ---------------------------------------- TITLE: Install jj on openSUSE Tumbleweed DESCRIPTION: Installs jj on openSUSE Tumbleweed by using the zypper package manager to install the jujutsu package from the official repositories. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/install-and-setup.md#_snippet_8 LANGUAGE: shell CODE: ``` zypper install jujutsu ``` ---------------------------------------- TITLE: Install jj from source (latest release) DESCRIPTION: Installs the latest release version of jj from its Git repository. Requires Rust version >= 1.85. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/install-and-setup.md#_snippet_2 LANGUAGE: shell CODE: ``` # To install the latest release cargo install --locked --bin jj jj-cli ``` ---------------------------------------- TITLE: Run jj using NixOS flake (prerelease) DESCRIPTION: Runs a prerelease version of jj directly from its Git repository flake on NixOS. This allows testing the latest development version without a formal installation. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/install-and-setup.md#_snippet_4 LANGUAGE: shell CODE: ``` nix run 'github:jj-vcs/jj' ``` ---------------------------------------- TITLE: Xonsh Standard Completions DESCRIPTION: Enables standard command-line completions for jj in Xonsh. It uses a helper command to source the completion script, making jj commands easier to use. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/install-and-setup.md#_snippet_17 LANGUAGE: shell CODE: ``` source-bash $(jj util completion) ``` ---------------------------------------- TITLE: Install jj on Arch Linux DESCRIPTION: Installs jj on Arch Linux using either the official extra repository via pacman or the AUR repository via an AUR helper like yay. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/install-and-setup.md#_snippet_3 LANGUAGE: shell CODE: ``` pacman -S jujutsu yay -S jujutsu-git ``` ---------------------------------------- TITLE: Install jj on macOS using MacPorts DESCRIPTION: Installs the latest release of jj on macOS using the MacPorts package manager. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/install-and-setup.md#_snippet_9 LANGUAGE: shell CODE: ``` sudo port install jujutsu ``` ---------------------------------------- TITLE: Fish Dynamic Completions DESCRIPTION: Configures dynamic command-line completions for jj in Fish shell. For Fish versions 4.0.2 and above, dynamic completions are loaded by default, simplifying the setup process. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/install-and-setup.md#_snippet_15 LANGUAGE: shell CODE: ``` COMPLETE=fish jj | source ``` ---------------------------------------- TITLE: Zsh Dynamic Completions DESCRIPTION: Sets up dynamic command-line completions for jj in Zsh. It requires loading the completion system and sourcing the dynamic completion script, which offers enhanced and context-aware suggestions. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/install-and-setup.md#_snippet_14 LANGUAGE: shell CODE: ``` source <(COMPLETE=zsh jj) ``` ---------------------------------------- TITLE: TOML Dotted Style Example DESCRIPTION: Demonstrates the equivalent TOML syntax for dotted style key-value pairs and nested tables, showing how to define template aliases and color configurations. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_0 LANGUAGE: TOML CODE: ``` template-aliases."format_short_id(id)" = "id.shortest(12)" colors."commit_id prefix".bold = true # is equivalent to: [template-aliases] "format_short_id(id)" = "id.shortest(12)" [colors] "commit_id prefix" = { bold = true } ``` ---------------------------------------- TITLE: Jujutsu Help Command Examples DESCRIPTION: Demonstrates how to use the `jj help` command to get information about Jujutsu commands and keywords. This is useful for learning and understanding specific functionalities. SOURCE: https://github.com/jj-vcs/jj/blob/main/README.md#_snippet_0 LANGUAGE: Shell CODE: ``` jj help rebase ``` LANGUAGE: Shell CODE: ``` jj help -k config ``` LANGUAGE: Shell CODE: ``` jj help --help ``` ---------------------------------------- TITLE: User Settings Configuration DESCRIPTION: Provides an example of user-specific configuration settings in TOML format, including name and email. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_1 LANGUAGE: TOML CODE: ``` [user] name = "YOUR NAME" email = "YOUR_EMAIL@example.com" ``` ---------------------------------------- TITLE: Powershell Standard Completions DESCRIPTION: Integrates standard command-line completions for jj into Powershell by adding a line to the user's profile script. This ensures that jj commands are autocompleted within the Powershell session. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/install-and-setup.md#_snippet_18 LANGUAGE: powershell CODE: ``` Invoke-Expression (& { (jj util completion power-shell | Out-String) }) ``` ---------------------------------------- TITLE: Configure 3-Pane Diff Editor (diffedit3) DESCRIPTION: Enables a 3-pane diff editing experience using diffedit3, which starts a local server accessible via a web browser. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_59 LANGUAGE: TOML CODE: ``` ui.diff-editor = "diffedit3" ``` ---------------------------------------- TITLE: Bash Dynamic Completions DESCRIPTION: Enables dynamic command-line completions for jj in Bash. This method leverages the `COMPLETE` environment variable to provide context-aware suggestions for subcommands, options, bookmarks, aliases, revisions, operations, and files. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/install-and-setup.md#_snippet_13 LANGUAGE: shell CODE: ``` source <(COMPLETE=bash jj) ``` ---------------------------------------- TITLE: Configure jj user name and email DESCRIPTION: Sets the user's name and email for jj commits. This configuration is stored globally for the user. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/install-and-setup.md#_snippet_12 LANGUAGE: shell CODE: ``` $ jj config set --user user.name "Martin von Zweigbergk" $ jj config set --user user.email "martinvonz@google.com" ``` ---------------------------------------- TITLE: Benchmark Using Tags and Bookmarks DESCRIPTION: Demonstrates how to use Git tags and bookmarks as revsets for benchmarking. SOURCE: https://github.com/jj-vcs/jj/blob/main/cli/testing/bench-revsets-git.txt#_snippet_3 LANGUAGE: shell CODE: ``` tags() bookmarks() ``` ---------------------------------------- TITLE: Configure GUI Editors for jj DESCRIPTION: Provides examples of configuring various GUI editors like VS Code, BBEdit, Sublime Text, TextMate, Notepad++, and IntelliJ as the default editor for jj. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_53 LANGUAGE: toml CODE: ``` [ui] editor = "code -w" # VS Code ``` LANGUAGE: toml CODE: ``` editor = "code.cmd -w" # VS Code on Windows ``` LANGUAGE: toml CODE: ``` editor = "bbedit -w" # BBEdit ``` LANGUAGE: toml CODE: ``` editor = "subl -n -w" # Sublime Text ``` LANGUAGE: toml CODE: ``` editor = "mate -w" # TextMate ``` LANGUAGE: toml CODE: ``` editor = ["C:/Program Files/Notepad++/notepad++.exe", "-multiInst", "-notabbar", "-nosession", "-noPlugin"] # Notepad++ ``` LANGUAGE: toml CODE: ``` editor = "idea --temp-project --wait" #IntelliJ ``` ---------------------------------------- TITLE: Install Development Tools for jj DESCRIPTION: Installs necessary Rust toolchains and development utilities like bacon, cargo-insta, and cargo-nextest for contributing to the jj project. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/contributing.md#_snippet_4 LANGUAGE: Shell CODE: ``` rustup toolchain add nightly rustup toolchain add 1.85 cargo install --locked bacon cargo install --locked cargo-insta cargo install --locked cargo-nextest ``` ---------------------------------------- TITLE: Enable Watchman Filesystem Monitor DESCRIPTION: Configures `jj` to use the Watchman filesystem monitor for tracking working copy changes, potentially improving performance in large repositories. Requires Watchman to be installed. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_102 LANGUAGE: toml CODE: ``` fsmonitor.backend = "watchman" ``` ---------------------------------------- TITLE: Install uv on Windows DESCRIPTION: Installs the 'uv' package manager on Windows using PowerShell, bypassing execution policy restrictions. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/contributing.md#_snippet_13 LANGUAGE: powershell CODE: ``` powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" ``` ---------------------------------------- TITLE: Install uv via Homebrew DESCRIPTION: Installs the 'uv' package manager using the Homebrew package manager. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/contributing.md#_snippet_14 LANGUAGE: shell CODE: ``` brew install uv ``` ---------------------------------------- TITLE: Configure jj short prefixes for revisions DESCRIPTION: Sets 'revsets.short-prefixes' to define shorter prefixes for certain revisions, prioritizing the current bookmark in this example. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_34 LANGUAGE: toml CODE: ``` [revsets] # Prioritize the current bookmark short-prefixes = "(main..@)::" ``` ---------------------------------------- TITLE: Specify Single Tags for Benchmarking DESCRIPTION: Demonstrates how to use single Git tags as revsets to specify versions for benchmarking. SOURCE: https://github.com/jj-vcs/jj/blob/main/cli/testing/bench-revsets-git.txt#_snippet_0 LANGUAGE: shell CODE: ``` v1.0.0 v2.40.0 ``` ---------------------------------------- TITLE: Install uv via Cargo DESCRIPTION: Installs the 'uv' package manager directly from its Git repository using Cargo, the Rust package manager. This method might take a while. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/contributing.md#_snippet_15 LANGUAGE: shell CODE: ``` cargo install --git https://github.com/astral-sh/uv uv ``` ---------------------------------------- TITLE: Benchmark Ancestors and Ranges DESCRIPTION: Provides examples of using revsets to benchmark ancestors and ranges of commits, including those related to tags and authors. SOURCE: https://github.com/jj-vcs/jj/blob/main/cli/testing/bench-revsets-git.txt#_snippet_11 LANGUAGE: shell CODE: ``` ::(v1.0.0..v2.40.0) author(peff).. ``` ---------------------------------------- TITLE: Load Config from File DESCRIPTION: Shows how to load an entire TOML configuration document from a specified file using the --config-file option. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_111 LANGUAGE: shell CODE: ``` jj --config-file=extra-config.toml log ``` ---------------------------------------- TITLE: Create Initial Commits with Content DESCRIPTION: Creates three initial commits with varying content in a file named 'file'. This setup is used to demonstrate moving content changes between commits. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/tutorial.md#_snippet_20 LANGUAGE: shell CODE: ``` $ jj new master -m abc; printf 'a\nb\nc\n' > file Working copy (@) now at: ztqrpvnw f94e49cf (empty) abc Parent commit (@-) : orrkosyo 7fd1a60b master | (empty) Merge pull request #6 from Spaceghost/patch-1 Added 0 files, modified 0 files, removed 1 files $ jj new -m ABC; printf 'A\nB\nc\n' > file Working copy (@) now at: kwtuwqnm 6f30cd1f (empty) ABC Parent commit (@-) : ztqrpvnw 51002261 ab $ jj new -m ABCD; printf 'A\nB\nC\nD\n' > file Working copy (@) now at: mrxqplyk a6749154 (empty) ABCD Parent commit (@-) : kwtuwqnm 30aecc08 ABC $ jj log -r master::@ @ mrxqplyk martinvonz@google.com 2023-02-12 19:38:21 b98c607b │ ABCD ○ kwtuwqnm martinvonz@google.com 2023-02-12 19:38:12 30aecc08 │ ABC ○ ztqrpvnw martinvonz@google.com 2023-02-12 19:38:03 51002261 │ abc ◆ orrkosyo octocat@nowhere.com 2012-03-06 15:06:50 master 7fd1a60b │ (empty) Merge pull request #6 from Spaceghost/patch-1 ~ ``` ---------------------------------------- TITLE: Define jj Alias for Log DESCRIPTION: An example of a jj alias named 'l' that displays commits on the working copy compared to the 'main' bookmark. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_48 LANGUAGE: toml CODE: ``` [aliases] l = ["log", "-r", "(main..@):: | (main..@)-"] ``` ---------------------------------------- TITLE: ANSI 256-Color Configuration DESCRIPTION: Shows how to apply colors from the ANSI 256-color palette to UI elements using the 'ansi-color-N' format. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_5 LANGUAGE: TOML CODE: ``` [colors] commit_id = "ansi-color-81" ``` ---------------------------------------- TITLE: Sparse Pattern Rule Examples DESCRIPTION: Provides examples of how sparse pattern rules are applied and canonicalized. It demonstrates the effect of include and exclude rules, and how different orderings of rules can lead to equivalent canonicalized sets. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/design/sparse-v2.md#_snippet_3 LANGUAGE: txt CODE: ``` # jj sparse set --add foo/bar is equal to jj sparse set --add include:dir:foo/bar # jj sparse set --add exclude:dir:foo/bar adds a new `Dir` type rule with `include = false` # jj sparse set --exclude foo/bar as a possible shorthand for the above # jj sparse list will print the explicit rules include:dir:foo exclude:dir:foo/bar include:dir:foo/bar/baz exclude:dir:foo/bar/baz/qux # Canonicalized include:dir:foo exclude:dir:foo/bar ``` ---------------------------------------- TITLE: Enable Automatic Local Bookmark Creation DESCRIPTION: Enables the automatic creation of local bookmarks that mirror new remote-tracking bookmarks imported from Git. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_92 LANGUAGE: toml CODE: ``` [git] auto-local-bookmark = true ``` ---------------------------------------- TITLE: Benchmark Intersection and Union of Tag Sets DESCRIPTION: Provides examples of using set operations (intersection and union) on revsets derived from tags for benchmarking. SOURCE: https://github.com/jj-vcs/jj/blob/main/cli/testing/bench-revsets-git.txt#_snippet_5 LANGUAGE: shell CODE: ``` tags() & ::v2.40.0 v2.39.0 & ::v2.40.0 author(peff) & committer(gitster) author(peff) | committer(gitster) ``` ---------------------------------------- TITLE: Build and Deploy Documentation with mike DESCRIPTION: This script utilizes 'uv run mike deploy' to build and deploy documentation. It accepts custom arguments and relies on the 'mike' tool. Ensure 'mike' is installed and configured for your project. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/contributing.md#_snippet_21 LANGUAGE: shell CODE: ``` uv run mike deploy ``` ---------------------------------------- TITLE: Useful JJ Revsets for Logging DESCRIPTION: Provides examples of powerful revset queries for logging revisions in Jujutsu. These examples cover logging revisions across local and remote bookmarks, filtering by author, and finding ancestors of the current working copy. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/github.md#_snippet_9 LANGUAGE: shell CODE: ``` $ jj log -r 'bookmarks() & ~(main | remote_bookmarks())' ``` LANGUAGE: shell CODE: ``` $ jj log -r 'mine() & bookmarks() & ~remote_bookmarks()' ``` LANGUAGE: shell CODE: ``` $ jj log -r 'remote_bookmarks() & (mine() | committer(your@email.com))' ``` LANGUAGE: shell CODE: ``` $ jj log -r 'remote_bookmarks()..@' ``` ---------------------------------------- TITLE: jj heads() function examples DESCRIPTION: Shows examples of the `heads()` function in jj-vcs, which returns the heads of a given set of commits. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_65 LANGUAGE: jj CODE: ``` heads(E|D) ``` LANGUAGE: jj CODE: ``` heads(E|C) ``` LANGUAGE: jj CODE: ``` heads(E|B) ``` LANGUAGE: jj CODE: ``` heads(E|A) ``` LANGUAGE: jj CODE: ``` heads(A) ``` ---------------------------------------- TITLE: Benchmark Roots and Heads of Tag Sets DESCRIPTION: Illustrates how to find the root and head commits of sets defined by tags using revsets for benchmarking. SOURCE: https://github.com/jj-vcs/jj/blob/main/cli/testing/bench-revsets-git.txt#_snippet_8 LANGUAGE: shell CODE: ``` roots(tags()) heads(tags()) ``` ---------------------------------------- TITLE: Override Default Commit Description DESCRIPTION: Allows overriding the default commit description template, for example, to automatically include issue closing information. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_10 LANGUAGE: toml CODE: ``` [template-aliases] default_commit_description = ''' "Closes #NNNN " ``` ---------------------------------------- TITLE: UI Color Output Setting DESCRIPTION: Shows how to configure the UI to control output colorization, with options for 'always', 'never', 'debug', and 'auto'. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_2 LANGUAGE: TOML CODE: ``` [ui] color = "never" # Turn off color ``` ---------------------------------------- TITLE: Multiple Label Styling DESCRIPTION: Illustrates how to apply styles to multiple labels or combine styles for specific elements, similar to CSS selectors. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_7 LANGUAGE: TOML CODE: ``` [colors] commit_id = "green" "working_copy commit_id" = { underline = true } ``` ---------------------------------------- TITLE: Configure Signing Backend DESCRIPTION: Sets the signing behavior to 'drop' and the backend to 'ssh' using a specific SSH key. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_87 LANGUAGE: toml CODE: ``` [signing] behavior = "drop" backend = "ssh" key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGj+J6N6SO+4P8dOZqfR1oiay2yxhhHnagH52avUqw5h" ``` ---------------------------------------- TITLE: Get JJ VCS User Config Path DESCRIPTION: Retrieves the path to the user-specific JJ VCS configuration directory. This command helps users locate where their global JJ configurations are stored. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_107 LANGUAGE: bash CODE: ``` jj config path --user ``` ---------------------------------------- TITLE: Install and Configure starship-jj (Bash/TOML) DESCRIPTION: Provides instructions to install the `starship-jj` crate using Cargo and configure Starship's `starship.toml` to use it for displaying jj status. It includes the necessary TOML configuration for the custom module. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/Starship.md#_snippet_4 LANGUAGE: bash CODE: ``` cargo install starship-jj --locked ``` LANGUAGE: toml CODE: ``` # Extend the default format config: https://starship.rs/config/#default-prompt-format format=""" ... ${custom.jj}\ ... """ #... [custom.jj] command = "prompt" format = "$output" ignore_timeout = true shell = ["starship-jj", "--ignore-working-copy", "starship"] use_stdin = false when = true ``` ---------------------------------------- TITLE: Benchmark Filtered History Ranges DESCRIPTION: Shows how to combine history range filtering with author/committer filters for benchmarking. SOURCE: https://github.com/jj-vcs/jj/blob/main/cli/testing/bench-revsets-git.txt#_snippet_7 LANGUAGE: shell CODE: ``` ::v1.0.0 & (author(peff) & committer(gitster)) ::v1.0.0 & (author(peff) | committer(gitster)) ``` ---------------------------------------- TITLE: Install uv on macOS/Linux DESCRIPTION: Installs the 'uv' package manager using a curl script for macOS and Linux systems. It also provides an option to prevent modification of the shell profile. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/contributing.md#_snippet_12 LANGUAGE: shell CODE: ``` curl -LsSf https://astral.sh/uv/install.sh | sh ``` LANGUAGE: shell CODE: ``` curl -LsSf https://astral.sh/uv/install.sh | env INSTALLER_NO_MODIFY_PATH=1 sh ``` ---------------------------------------- TITLE: Configure sequential execution for sorting and truncating numbers DESCRIPTION: This example demonstrates controlling the execution order of multiple tools applied to the same file. '1-sort-numbers-file' sorts the numbers numerically, and '2-truncate-numbers-file' keeps only the first 10 lines, ensuring the correct order for processing. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_73 LANGUAGE: toml CODE: ``` [fix.tools.1-sort-numbers-file] command = ["sort", "-n"] patterns = ["numbers.txt"] [fix.tools.2-truncate-numbers-file] command = ["head", "-n", "10"] patterns = ["numbers.txt"] ``` ---------------------------------------- TITLE: Allow Pushing New Bookmarks DESCRIPTION: Enables pushing newly-created bookmarks by default, avoiding the need to specify the '--allow-new' flag for 'jj git push'. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_96 LANGUAGE: toml CODE: ``` [git] push-new-bookmarks = true ``` ---------------------------------------- TITLE: Benchmark Filters within Small Sets DESCRIPTION: Demonstrates how to apply filters like `files`, `empty`, and `conflicts` within a limited range of commits for benchmarking. SOURCE: https://github.com/jj-vcs/jj/blob/main/cli/testing/bench-revsets-git.txt#_snippet_15 LANGUAGE: shell CODE: ``` files(root:"Makefile") & v1.0.0..v1.2.0 empty() & v1.0.0..v1.2.0 conflicts() & v1.0.0..v1.2.0 ``` ---------------------------------------- TITLE: jj roots() function examples DESCRIPTION: Provides examples for the `roots()` function in jj-vcs, which identifies the root commits in a given set. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_66 LANGUAGE: jj CODE: ``` roots(E|D) ``` LANGUAGE: jj CODE: ``` roots(E|C) ``` LANGUAGE: jj CODE: ``` roots(E|B) ``` LANGUAGE: jj CODE: ``` roots(E|A) ``` LANGUAGE: jj CODE: ``` roots(A) ``` ---------------------------------------- TITLE: Specify SSH Keygen Program Path DESCRIPTION: Allows setting a custom path for the ssh-keygen binary used by the SSH signing backend. This is useful if ssh-keygen is installed in a non-standard location. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_83 LANGUAGE: toml CODE: ``` [signing] backends.ssh.program = "/path/to/ssh-keygen" ``` ---------------------------------------- TITLE: Configure jj default log revset DESCRIPTION: Defines the default revision set for 'jj log' when no specific revisions or paths are provided. This example shows commits not in 'main@origin'. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_26 LANGUAGE: toml CODE: ``` [revsets] # Show commits that are not in `main@origin` log = "main@origin.." ``` ---------------------------------------- TITLE: Configure jj log-graph-prioritize revset DESCRIPTION: Prioritizes specific revsets in the 'jj log' graph display to improve readability, especially with large merges. This example prioritizes commits with 'megamerge' in their description, falling back to 'trunk()'. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_27 LANGUAGE: toml CODE: ``` [revsets] log-graph-prioritize = "coalesce(description("megamerge\n"), trunk())" ``` ---------------------------------------- TITLE: Benchmark Roots and Heads of Author Sets DESCRIPTION: Demonstrates how to find the root and head commits of sets filtered by author using revsets for benchmarking. SOURCE: https://github.com/jj-vcs/jj/blob/main/cli/testing/bench-revsets-git.txt#_snippet_9 LANGUAGE: shell CODE: ``` roots(author(peff)) heads(author(peff)) ``` ---------------------------------------- TITLE: jj Rebase Example DESCRIPTION: Demonstrates a sequence of jj rebase operations to illustrate how rebasing and then re-rebasing can return to a previous state, highlighting the importance of lossless rebasing. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/design/copy-tracking.md#_snippet_0 LANGUAGE: console CODE: ``` $ jj log C rename bar->baz | B rename foo->bar | A add foo $ jj rebase -r C -d A $ jj rebase -r C -d B # Takes us back to the state above ``` ---------------------------------------- TITLE: Configure jj default templates for log and evolog DESCRIPTION: Sets the default templates for various jj commands including 'evolog', 'log', 'show', and operation logs/shows. It allows specifying built-in templates for different display formats. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_28 LANGUAGE: toml CODE: ``` [templates] # Use builtin evolog template evolog = "builtin_evolog_compact" # Use builtin log template log = "builtin_log_compact" # Use builtin show template show = "builtin_log_detailed" # Use builtin op log template op_log = "builtin_op_log_compact" # Use builtin op log template op_show = "builtin_op_log_compact" ``` LANGUAGE: toml CODE: ``` [templates] log = "builtin_log_compact_full_description" ``` ---------------------------------------- TITLE: Set Default Editor to Pico DESCRIPTION: Configures the default editor for jj to 'pico'. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_51 LANGUAGE: toml CODE: ``` [ui] editor = "pico" ``` ---------------------------------------- TITLE: Configure Pager Ruler Visibility DESCRIPTION: Sets whether the ruler is displayed by default when the jj built-in pager starts. It can be configured to be shown or hidden. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_45 LANGUAGE: toml CODE: ``` [ui.streampager] # Start with the ruler showing show-ruler = true # (default) # Start with the ruler hidden show-ruler = false ``` ---------------------------------------- TITLE: Linting and Formatting with JJ run DESCRIPTION: Examples of using the 'jj run' command for linting and formatting tasks. These commands can be applied to specific revisions or the current working copy. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/design/run.md#_snippet_0 LANGUAGE: shell CODE: ``` jj run 'pre-commit run' -r $revset jj run 'cargo clippy' -r $revset jj run 'cargo +nightly fmt' ``` ---------------------------------------- TITLE: Benchmark Author and Committer Filters DESCRIPTION: Demonstrates how to filter commits based on author and committer names using revsets for benchmarking. SOURCE: https://github.com/jj-vcs/jj/blob/main/cli/testing/bench-revsets-git.txt#_snippet_6 LANGUAGE: shell CODE: ``` author(peff) committer(gitster) ``` ---------------------------------------- TITLE: Register Watchman Snapshot Trigger DESCRIPTION: Enables `jj` to use Watchman triggers to automatically create working copy snapshots when filesystem changes are detected. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_103 LANGUAGE: toml CODE: ``` fsmonitor.watchman.register-snapshot-trigger = true ``` ---------------------------------------- TITLE: Custom Hex Color Configuration DESCRIPTION: Demonstrates setting custom colors using 6-digit hexadecimal codes for UI elements. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_4 LANGUAGE: TOML CODE: ``` [colors] change_id = "#ff1525" ``` ---------------------------------------- TITLE: Format Time Range Absolute DESCRIPTION: Sets the template alias for `format_time_range` to display an absolute time range, combining start and end times. This overrides the default relative timestamp behavior. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_37 LANGUAGE: toml CODE: ``` [template-aliases] 'format_time_range(time_range)' = 'time_range.start() ++ " - " ++ time_range.end()' ``` ---------------------------------------- TITLE: Benchmark Roots and Heads of History Ranges DESCRIPTION: Shows how to find the root and head commits of specific history ranges using revsets for benchmarking. SOURCE: https://github.com/jj-vcs/jj/blob/main/cli/testing/bench-revsets-git.txt#_snippet_10 LANGUAGE: shell CODE: ``` roots(::v2.40.0) heads(::v2.40.0) ``` ---------------------------------------- TITLE: Enable Rustfmt Tool in Repository DESCRIPTION: Shows how to enable a previously disabled tool (rustfmt) for a specific repository using the jj config command. This allows for granular control over tool execution. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_75 LANGUAGE: shell CODE: ``` $ jj config set --repo fix.tools.rustfmt.enabled true ``` ---------------------------------------- TITLE: Enable and Format Cryptographic Signatures DESCRIPTION: Enables the display of cryptographic signatures and customizes their short format. It handles cases where a signature might be absent. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_40 LANGUAGE: toml CODE: ``` [ui] # default is false show-cryptographic-signatures = true [template-aliases] 'format_short_cryptographic_signature(sig)' = ''' if(sig, sig.status(), "(no sig)", ) ''' ``` ---------------------------------------- TITLE: jj alias definition examples DESCRIPTION: Shows how to define aliases in jj-vcs configuration files, including simple symbol mapping and function overloading. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_70 LANGUAGE: toml CODE: ``` [revset-aliases] 'HEAD' = '@-' 'user()' = 'user("me@example.org")' 'user(x)' = 'author(x) | committer(x)' ``` ---------------------------------------- TITLE: Customize jj commit and change ID display format DESCRIPTION: Customizes how short commit and change IDs are displayed in jj using the 'format_short_id()' template alias. Examples include showing the shortest unique prefix, highlighting it, or always displaying a fixed length. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_32 LANGUAGE: toml CODE: ``` [template-aliases] # Highlight unique prefix and show at least 12 characters (default) 'format_short_id(id)' = 'id.shortest(12)' # Just the shortest possible unique prefix 'format_short_id(id)' = 'id.shortest()' # Show unique prefix and the rest surrounded by brackets 'format_short_id(id)' = 'id.shortest(12).prefix() ++ "[" ++ id.shortest(12).rest() ++ "]"' # Always show 12 characters 'format_short_id(id)' = 'id.short(12)' ``` LANGUAGE: toml CODE: ``` [template-aliases] # Uppercase change ids. `jj` treats change and commit ids as case-insensitive. 'format_short_change_id(id)' = 'format_short_id(id).upper()' ``` ---------------------------------------- TITLE: Custom Color Configuration DESCRIPTION: Illustrates how to set custom colors for UI elements like commit IDs using basic color names. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_3 LANGUAGE: TOML CODE: ``` [colors] commit_id = "green" ``` ---------------------------------------- TITLE: Condition: Command Matching DESCRIPTION: Details the --when.commands condition, which enables configuration based on matching the currently executing command against a list of command prefixes. Matching is done by prefix, and multiple commands can be specified. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_115 LANGUAGE: toml CODE: ``` # --when.commands: List of subcommands to match. # Subcommands are space-separated and matched by prefix. # # ```toml # --when.commands = ["file"] # matches `jj file show`, `jj file list`, etc # --when.commands = ["file show"] # matches `jj file show` but *NOT* `jj file list` # --when.commands = ["file", "log"] # matches `jj file` *OR* `jj log` (or subcommand of either) # ``` ``` ---------------------------------------- TITLE: Benchmark Parents and Ancestors of Commits DESCRIPTION: Demonstrates how to use revsets to select parents and ancestors of specific commits, including older and recent ones, and tag-based sets. SOURCE: https://github.com/jj-vcs/jj/blob/main/cli/testing/bench-revsets-git.txt#_snippet_12 LANGUAGE: shell CODE: ``` v1.0.0- v1.0.0--- ::v1.0.0--- v2.40.0- v2.40.0--- ::v2.40.0--- tags()- tags()--- ::tags()--- ``` ---------------------------------------- TITLE: Jujutsu: Push Change with Auto-Generated Bookmark DESCRIPTION: This example shows how to push a specific change ('mw') in a Jujutsu repository, allowing Jujutsu to automatically create a bookmark for the push. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/github.md#_snippet_4 LANGUAGE: shell CODE: ``` $ jj commit $ jj git push --change mw ``` ---------------------------------------- TITLE: Benchmark Local Changes Relative to Tags/Bookmarks DESCRIPTION: Shows how to benchmark local changes by defining a revset that includes commits not present in tags or remote bookmarks. SOURCE: https://github.com/jj-vcs/jj/blob/main/cli/testing/bench-revsets-git.txt#_snippet_4 LANGUAGE: shell CODE: ``` (tags() | remote_bookmarks()).. ``` ---------------------------------------- TITLE: Track Git Bookmarks DESCRIPTION: Commands to track or untrack specific bookmarks from remote repositories. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_93 LANGUAGE: sh CODE: ``` # import feature1 bookmark and start tracking it jj bookmark track feature1@origin # delete local gh-pages bookmark and stop tracking it jj bookmark delete gh-pages jj bookmark untrack gh-pages@upstream ``` ---------------------------------------- TITLE: Configure sort for word list files DESCRIPTION: This configuration uses the 'sort -u' command to sort a text file alphabetically and remove duplicate words. It's an example of using 'jj fix' with tools that are not strictly code formatters. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_70 LANGUAGE: toml CODE: ``` [fix.tools.sort-word-list] command = ["sort", "-u"] patterns = ["word_list.txt"] ``` ---------------------------------------- TITLE: Enable Git Signature Verification DESCRIPTION: Enables the display of commit signatures in the UI by setting 'ui.show-cryptographic-signatures' to true. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_88 LANGUAGE: toml CODE: ``` ui.show-cryptographic-signatures = true ``` ---------------------------------------- TITLE: Advanced UI Color Styling DESCRIPTION: Explains how to configure foreground (fg), background (bg), and text styles (bold, italic, underline) for UI elements using TOML tables. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_6 LANGUAGE: TOML CODE: ``` [colors] commit_id = { fg = "green", bg = "#ff1525", bold = true, underline = true } change_id = { reverse = true, italic = true } ``` ---------------------------------------- TITLE: Console Example: Rebasing Unrelated Renames DESCRIPTION: This example shows a rebase operation where a rename in one commit is unrelated to a file created in another. It highlights that changes are not propagated if the files have different origins or salts. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/design/copy-tracking.md#_snippet_9 LANGUAGE: console CODE: ``` N rename foo->bar | | M create foo="M" | | | L delete foo |/ K add foo="K" ``` ---------------------------------------- TITLE: SSH Port Forwarding for diffedit3 DESCRIPTION: Sets up SSH port forwarding to allow diffedit3 to communicate with its local server when accessed over SSH. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_61 LANGUAGE: shell CODE: ``` ssh -L 17376:localhost:17376 \ -L 17377:localhost:17377 \ -L 17378:localhost:17378 \ -L 17379:localhost:17379 \ -L 17380:localhost:17380 \ myhost.example.com ``` ---------------------------------------- TITLE: Set Default Editor to NeoVim DESCRIPTION: Configures the default editor for jj to 'nvim'. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_52 LANGUAGE: toml CODE: ``` [ui] editor = "nvim" ``` ---------------------------------------- TITLE: Specify GPG Program Path DESCRIPTION: Allows customization of the GPG program used by the gpg backend. This is useful if 'gpg' is not in the system's PATH or if a different version like 'gpg2' is preferred. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_77 LANGUAGE: toml CODE: ``` [signing] backends.gpg.program = "gpg2" ``` ---------------------------------------- TITLE: Jujutsu: Push with Named Bookmark DESCRIPTION: This example shows how to create a new commit, add a feature, create a named bookmark 'bar', and then push that bookmark to GitHub. It highlights creating the bookmark on the parent of the working-copy commit. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/github.md#_snippet_1 LANGUAGE: shell CODE: ``` $ jj new main $ jj commit -m 'refactor(foo): restructure foo()' $ jj commit -m 'feat(bar): add support for bar' $ jj bookmark create bar -r @- $ jj git push --allow-new ``` ---------------------------------------- TITLE: View Git Command Help in Jujutsu DESCRIPTION: Provides help documentation for the `jj git` family of commands. You can get general help for `jj git` or specific help for commands like `jj git push`. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/git-compatibility.md#_snippet_3 LANGUAGE: bash CODE: ``` jj help git ``` LANGUAGE: bash CODE: ``` jj help git push ``` LANGUAGE: bash CODE: ``` jj git push -h ``` ---------------------------------------- TITLE: Serve jj documentation locally DESCRIPTION: Builds and serves the jj project documentation locally using 'uv' and 'mkdocs'. The documentation can be viewed at http://127.0.0.1:8000 and automatically reloads on changes to .md files. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/contributing.md#_snippet_16 LANGUAGE: shell CODE: ``` uv run mkdocs serve ``` ---------------------------------------- TITLE: Timestamp Range Methods DESCRIPTION: Illustrates the methods available for the TimestampRange type, including retrieving the start and end timestamps and calculating the duration. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_45 LANGUAGE: any CODE: ``` TimestampRange.start() TimestampRange.end() TimestampRange.duration() ``` ---------------------------------------- TITLE: Condition: Repository Path Matching DESCRIPTION: Explains the --when.repositories condition, which allows configuration to be enabled based on matching the repository path prefix against a list of provided paths. Paths are case-sensitive and '~' expands to the home directory. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_114 LANGUAGE: toml CODE: ``` # --when.repositories: List of paths to match the repository path prefix. # Paths should be absolute. Each path component (directory or file name, drive # letter, etc.) is compared case-sensitively on all platforms. A path starting # with `~` is expanded to the home directory. On Windows, directory separator may # be either `\` or `/`. (Beware that `\` needs escape in double-quoted strings.) # # Use `jj root` to see the workspace root directory. Note that the repository path # is in the main workspace if you're using multiple workspaces with `jj # workspace`. ``` ---------------------------------------- TITLE: Benchmark Non-Commit Object Filters DESCRIPTION: Illustrates how to use revsets to filter based on conditions that do not directly read commit objects, such as merges. SOURCE: https://github.com/jj-vcs/jj/blob/main/cli/testing/bench-revsets-git.txt#_snippet_14 LANGUAGE: shell CODE: ``` merges() ~merges() ``` ---------------------------------------- TITLE: CommitId Methods DESCRIPTION: Provides methods to get short representations and the shortest unique prefix of a CommitId. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_26 LANGUAGE: jj-vcs CODE: ``` `.short([len: Integer]) -> String` .shortest([min_len: Integer]) -> ShortestIdPrefix ``` ---------------------------------------- TITLE: Benchmark Children and Descendants of Commits DESCRIPTION: Shows how to use revsets to select children and descendants of specific commits, including older and recent ones, and tag-based sets. SOURCE: https://github.com/jj-vcs/jj/blob/main/cli/testing/bench-revsets-git.txt#_snippet_13 LANGUAGE: shell CODE: ``` v1.0.0+ v1.0.0+++ v1.0.0+++:: v2.40.0+ v2.40.0+++ v2.40.0+++:: tags()+ tags()+++ tags()+++:: ``` ---------------------------------------- TITLE: Benchmark Using Tag History Ranges DESCRIPTION: Shows how to define ranges of commit history using tags for benchmarking purposes. This includes direct ranges and ranges relative to tags. SOURCE: https://github.com/jj-vcs/jj/blob/main/cli/testing/bench-revsets-git.txt#_snippet_1 LANGUAGE: shell CODE: ``` ::v1.0.0 ..v1.0.0 ::v2.40.0 ..v2.40.0 v2.39.0..v2.40.0 ::v2.40.0 ~ ::v2.39.0 v2.39.0::v2.40.0 ``` ---------------------------------------- TITLE: jj reachable() function examples DESCRIPTION: Demonstrates the usage of the `reachable()` function in jj-vcs, showing the set of reachable commits from a given commit. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_63 LANGUAGE: jj CODE: ``` reachable(E, A..) ``` LANGUAGE: jj CODE: ``` reachable(D, A..) ``` LANGUAGE: jj CODE: ``` reachable(C, A..) ``` LANGUAGE: jj CODE: ``` reachable(B, A..) ``` LANGUAGE: jj CODE: ``` reachable(A, A..) ``` ---------------------------------------- TITLE: Run Development Commands for jj DESCRIPTION: Executes common development workflows for jj, including linting, formatting, and running tests, utilizing tools like bacon and nextest. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/contributing.md#_snippet_5 LANGUAGE: Shell CODE: ``` bacon clippy-all cargo +nightly fmt cargo nextest run --workspace cargo insta test --workspace --test-runner nextest ``` ---------------------------------------- TITLE: Profile JJ with Samply DESCRIPTION: Samply is a sampling profiler that can be used to analyze the performance of jj. Install samply via cargo and then run it with the 'record' command followed by the jj command you want to profile. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/contributing.md#_snippet_24 LANGUAGE: shell CODE: ``` cargo install samply samply record jj diff ``` ---------------------------------------- TITLE: Build jj documentation for offline distribution DESCRIPTION: Builds the jj project documentation for offline distribution using 'uv', 'mkdocs', and an environment variable to enable offline mode. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/contributing.md#_snippet_17 LANGUAGE: shell CODE: ``` MKDOCS_OFFLINE=true uv run mkdocs build ``` ---------------------------------------- TITLE: Configure Pager with diff-so-fancy DESCRIPTION: This TOML configuration sets up a pager to process output using 'diff-so-fancy' before displaying it in 'less'. It requires a subshell to execute the formatter. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_46 LANGUAGE: toml CODE: ``` [ui] pager = ["sh", "-c", "diff-so-fancy | less -RFX"] ``` ---------------------------------------- TITLE: Configure Custom Diff Editor with Arguments DESCRIPTION: Configures jj to use a custom binary for diff editing, specifying its path and command-line arguments, including placeholders for left and right directory paths. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_56 LANGUAGE: TOML CODE: ``` diff-editor = ["/path/to/binary", "--be-helpful", "$left", "$right"] ``` ---------------------------------------- TITLE: Specify Config via Command Line DESCRIPTION: Demonstrates how to set configuration options directly on the command line using the --config flag. This method overrides settings from config files or environment variables. The configuration values are expected in TOML format. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_110 LANGUAGE: shell CODE: ``` jj --config ui.color=always --config ui.diff-editor=meld split ``` LANGUAGE: shell CODE: ``` jj log --config \ 'template-aliases."format_timestamp(timestamp)"="""timestamp.format("%Y-%m-%d %H:%M %:::z")""""' ``` ---------------------------------------- TITLE: Example usage of jj-nu-log DESCRIPTION: Demonstrates how to use the `jj-nu-log` function with a specific revset and columns, including updating the author timestamp to a datetime object. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/Nushell.md#_snippet_2 LANGUAGE: nushell CODE: ``` jj-nu-log -r something change_id description "author.email()" "author.timestamp()" | update author_timestamp {into datetime} ``` ---------------------------------------- TITLE: Specify GPGsm Program Path DESCRIPTION: Enables the specification of the GPGsm program path for the gpgsm backend. This provides flexibility in choosing the GPGsm executable, especially if it's not found in the default system PATH. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_80 LANGUAGE: toml CODE: ``` [signing] backends.gpgsm.program = "gpgsm" ``` ---------------------------------------- TITLE: Configure Automatic Commit Trailers DESCRIPTION: Defines a template for automatically adding trailers to commit descriptions. Trailers are deduplicated based on the entire line or can be managed using 'trailers.contains_key()'. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_13 LANGUAGE: toml CODE: ``` [templates] commit_trailers = ''' format_signed_off_by_trailer(self) ++ if(!trailers.contains_key("Change-Id"), format_gerrit_change_id_trailer(self))''' ``` ---------------------------------------- TITLE: Configure Meld Merge Tool DESCRIPTION: This TOML snippet defines configuration for the 'meld' merge tool, likely used for diff editing within jj. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_54 LANGUAGE: toml CODE: ``` [merge-tools.meld] ``` ---------------------------------------- TITLE: jj connected() function examples DESCRIPTION: Illustrates the `connected()` function in jj-vcs, which finds commits connected to a given set of commits. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_64 LANGUAGE: jj CODE: ``` connected(E|A) ``` LANGUAGE: jj CODE: ``` connected(D|A) ``` LANGUAGE: jj CODE: ``` connected(A) ``` ---------------------------------------- TITLE: Benchmark Recent History Using Tags DESCRIPTION: Illustrates how to benchmark recent commit history relative to a specific tag, including commits after a tag and commits between two tags. SOURCE: https://github.com/jj-vcs/jj/blob/main/cli/testing/bench-revsets-git.txt#_snippet_2 LANGUAGE: shell CODE: ``` v2.40.0-.. ~(::v2.40.0) ``` ---------------------------------------- TITLE: Configure 3-Pane Diff Editor (Meld) DESCRIPTION: Enables a 3-pane diff editing experience using Meld, allowing side-by-side comparison of diffs and an editing pane. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_58 LANGUAGE: TOML CODE: ``` ui.diff-editor = "meld-3" ``` ---------------------------------------- TITLE: Build and deploy jj documentation (specific version) DESCRIPTION: Builds and deploys the jj documentation for a specific version (e.g., 'v1.33.1') and sets it as the 'latest' release. This involves checking out the version and then running the deployment script. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/contributing.md#_snippet_19 LANGUAGE: bash CODE: ``` jj new v1.33.1 .github/scripts/docs-build-deploy v1.33.1 latest --push ``` ---------------------------------------- TITLE: Configure Meld Diff Editor DESCRIPTION: Sets the default diff editor to 'meld' and specifies arguments for opening in a new tab, passing left and right directory paths. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_55 LANGUAGE: TOML CODE: ``` program = "meld" # Defaults to the name of the tool if not specified program = "/path/to/meld" # May be necessary if `meld` is not in the PATH edit-args = ["--newtab", "$left", "$right"] ``` ---------------------------------------- TITLE: Suppress Diff Instructions File DESCRIPTION: Disables the creation of the synthetic 'JJ-INSTRUCTIONS' file that is included in diffs during editing. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_63 LANGUAGE: TOML CODE: ``` ui.diff-instructions = false ``` ---------------------------------------- TITLE: Get CHANGELOG diff DESCRIPTION: This command retrieves the difference in the CHANGELOG.md file between the latest tags and the main branch, useful for identifying changes to be included in the release notes. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/releasing.md#_snippet_0 LANGUAGE: shell CODE: ``` jj log -r 'heads(tags())' # Check that this shows the previous version jj diff --from 'heads(tags())' --to main CHANGELOG.md ``` ---------------------------------------- TITLE: jj fork_point() function examples DESCRIPTION: Demonstrates the `fork_point()` function in jj-vcs, which finds the common ancestor or fork point between commits. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_67 LANGUAGE: jj CODE: ``` fork_point(E|D) ``` LANGUAGE: jj CODE: ``` fork_point(E|C) ``` LANGUAGE: jj CODE: ``` fork_point(E|B) ``` LANGUAGE: jj CODE: ``` fork_point(E|A) ``` LANGUAGE: jj CODE: ``` fork_point(D|C) ``` LANGUAGE: jj CODE: ``` fork_point(D|B) ``` LANGUAGE: jj CODE: ``` fork_point(B|C) ``` LANGUAGE: jj CODE: ``` fork_point(A) ``` LANGUAGE: jj CODE: ``` fork_point(none()) ``` ---------------------------------------- TITLE: Condition: Platform Matching DESCRIPTION: Describes the --when.platforms condition, which allows configuration to be enabled based on the operating system or family. It uses values from `std::env::consts::FAMILY` and `std::env::consts::OS`. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_116 LANGUAGE: toml CODE: ``` # --when.platforms: List of platforms to match. # The values are defined by both # [`std::env::consts::FAMILY](https://doc.rust-lang.org/std/env/consts/constant.FAMILY.html) # and # [`std::env::consts::OS](https://doc.rust-lang.org/std/env/consts/constant.OS.html). # # ```toml # --when.platforms = ["windows"] # matches only Windows # --when.platforms = ["linux", "freebsd"] # matches Linux or and FreeBSD, but not macOS # --when.platforms = ["unix"] # matches anything in the Unix family (Linux, FreeBSD, macOS, etc.) # ``` ``` ---------------------------------------- TITLE: Build and deploy jj documentation (prerelease) DESCRIPTION: Builds the prerelease version of the jj documentation, deploys it to the 'gh-pages' branch, and pushes the changes. This script is typically used in CI environments. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/contributing.md#_snippet_18 LANGUAGE: bash CODE: ``` .github/scripts/docs-build-deploy prerelease main --push ``` ---------------------------------------- TITLE: Configure Default Diff Editor DESCRIPTION: Sets the default diff editor to a specified tool name, such as 'meld', 'kdiff3', or 'diffedit3'. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_57 LANGUAGE: TOML CODE: ``` diff-editor = "meld" # Or `kdiff3`, or `diffedit3`, ... ``` ---------------------------------------- TITLE: Copy onto Deleted File Example DESCRIPTION: Shows how jj handles diffs when a file is copied onto a previously deleted file, illustrating the diff representation from K to M and M to K. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/design/copy-tracking.md#_snippet_7 LANGUAGE: console CODE: ``` M copy foo->bar | L delete bar | K add foo, bar ``` ---------------------------------------- TITLE: Specify Git Executable Path DESCRIPTION: Allows setting a custom path for the `git` executable if it's not on the system's PATH or if a specific version is required for remote interactions. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_99 LANGUAGE: toml CODE: ``` [git] executable-path = "/path/to/git" ``` ---------------------------------------- TITLE: Create Commits with jj DESCRIPTION: Demonstrates creating a series of commits using `jj new` and modifying files. It shows how to create commits 'A', 'B1', 'B2', and 'C', with 'B1' and 'B2' modifying the same file, and 'C' modifying a different file. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/tutorial.md#_snippet_12 LANGUAGE: shell CODE: ``` $ jj new master -m A; echo a > file1 Working copy (@) now at: nuvyytnq 00a2aeed (empty) A Parent commit (@-) : orrkosyo 7fd1a60b master | (empty) Merge pull request #6 from Spaceghost/patch-1 Added 0 files, modified 1 files, removed 0 files $ jj new -m B1; echo b1 > file1 Working copy (@) now at: ovknlmro 967d9f9f (empty) B1 Parent commit (@-) : nuvyytnq 5dda2f09 A $ jj new -m B2; echo b2 > file1 Working copy (@) now at: puqltutt 8ebeaffa (empty) B2 Parent commit (@-) : ovknlmro 7d7c6e6b B1 $ jj new -m C; echo c > file2 Working copy (@) now at: qzvqqupx 62a3c6d3 (empty) C Parent commit (@-) : puqltutt daa6ffd5 B2 $ jj log @ qzvqqupx martinvonz@google.com 2023-02-12 15:07:41 2370ddf3 │ C ○ puqltutt martinvonz@google.com 2023-02-12 15:07:33 daa6ffd5 │ B2 ○ ovknlmro martinvonz@google.com 2023-02-12 15:07:24 7d7c6e6b │ B1 ○ nuvyytnq martinvonz@google.com 2023-02-12 15:07:05 5dda2f09 │ A │ ○ kntqzsqt martinvonz@google.com 2023-02-12 14:56:59 5d39e19d ├─╯ Say goodbye ◆ orrkosyo octocat@nowhere.com 2012-03-06 15:06:50 master 7fd1a60b │ (empty) Merge pull request #6 from Spaceghost/patch-1 ~ ``` ---------------------------------------- TITLE: Configure Biome CLI for workspace tools (Windows) DESCRIPTION: This configuration demonstrates using a workspace-stored tool like the Biome CLI on Windows. It utilizes the '$root' variable to create an absolute path to the Windows executable. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_72 LANGUAGE: toml CODE: ``` # Windows command = ["$root\node_modules\@biomejs\cli-win32-x64\biome.exe"] ``` ---------------------------------------- TITLE: Configure Git Push Bookmark Naming DESCRIPTION: Generates bookmark names with a custom prefix and formatting for git push operations using the `templates.git_push_bookmark` TOML template. It allows for dynamic naming based on `change_id`. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_97 LANGUAGE: toml CODE: ``` [templates] git_push_bookmark = '"martinvonz/push-" ++ change_id.short()' ``` ---------------------------------------- TITLE: Initialize Jujutsu Repo from Existing Git Repo DESCRIPTION: Creates a Jujutsu repository backed by an existing Git repository on disk. This setup functions similarly to a Git worktree, with separate working copy files and commit records, but shared commit accessibility. Use `jj git import` to sync changes from Git to Jujutsu, and `jj git export` to sync from Jujutsu to Git. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/git-compatibility.md#_snippet_1 LANGUAGE: bash CODE: ``` jj git init --git-repo= ``` ---------------------------------------- TITLE: Conditional Configuration Across Multiple Files DESCRIPTION: Demonstrates how to use the --when flag at the top level of TOML files, enabling the splitting of configurations across multiple files. The conditions applied here are the same as those used in scope tables. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_113 LANGUAGE: toml CODE: ``` # In $XDG_CONFIG_HOME/jj/config.toml [user] name = "YOUR NAME" email = "YOUR_DEFAULT_EMAIL@example.com" ``` LANGUAGE: toml CODE: ``` # In $XDG_CONFIG_HOME/jj/conf.d/work.toml --when.repositories = ["~/the/work/repo"] [user] email = "YOUR_WORK_EMAIL@workplace.com" [revset-aliases] work = "heads(::@ ~ description(exact:''))::" [aliases] wip = ["log", "-r", "work"] ``` ---------------------------------------- TITLE: Customize Duplicate Commit Description DESCRIPTION: Specifies a template to customize the description copied when duplicating a commit. It receives the original commit object as input. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_11 LANGUAGE: toml CODE: ``` [templates] duplicate_description = ''' concat( description, "\n(cherry picked from commit ", commit_id, ")" ) ''' ``` ---------------------------------------- TITLE: jj Backout Example DESCRIPTION: Illustrates the use of `jj backout` to reverse a commit, showing how backing out a commit should result in an empty diff when comparing the state before and after the backout. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/design/copy-tracking.md#_snippet_1 LANGUAGE: console CODE: ``` $ jj log B rename foo->bar | A add foo $ jj backout -r B -d B $ jj diff --from B- --to B+ # Should be empty ``` ---------------------------------------- TITLE: Explore GitHub Repository with jj DESCRIPTION: Demonstrates how to use the Jujutsu version control system to explore a GitHub repository. This functionality leverages the Git backend, allowing seamless interaction with standard Git remotes. SOURCE: https://github.com/jj-vcs/jj/blob/main/README.md#_snippet_1 LANGUAGE: Shell CODE: ``` jj clone ``` ---------------------------------------- TITLE: Configure jj Plugins with AstroNvim DESCRIPTION: This Lua code snippet demonstrates how to configure multiple jj plugins simultaneously using AstroNvim's Lazy.nvim package manager. It imports the jj pack from the AstroCommunity repository, simplifying the setup process for users who want to leverage these integrations. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/Vim,-Neovim.md#_snippet_5 LANGUAGE: lua CODE: ``` { "AstroNvim/astrocommunity", { import = "astrocommunity.pack.jj" }, } ``` ---------------------------------------- TITLE: Set Default Git Push Remote DESCRIPTION: Configures the default remote for 'jj git push' to 'github'. Currently only supports a single remote. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_91 LANGUAGE: sh CODE: ``` jj config set --repo git.push "github" ``` ---------------------------------------- TITLE: Execute Custom jj Script Alias DESCRIPTION: Defines an alias 'my-script' to execute a custom jj script named 'my-jj-script' using 'jj util exec'. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_49 LANGUAGE: toml CODE: ``` [aliases] my-script = ["util", "exec", "--", "my-jj-script"] ``` ---------------------------------------- TITLE: Timestamp Formatting DESCRIPTION: Examples of using the Timestamp type's methods for formatting dates and times. Includes formatting with a custom string and converting to UTC or local time. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_44 LANGUAGE: any CODE: ``` Timestamp.ago() Timestamp.format(format: String) Timestamp.utc() Timestamp.local() ``` ---------------------------------------- TITLE: Configure jj graph style DESCRIPTION: Sets the visual style for commit graphs in jj. Options include 'curved', 'square', 'ascii', and 'ascii-large'. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_29 LANGUAGE: toml CODE: ``` [ui] # Possible values: "curved" (default), "square", "ascii", "ascii-large" graph.style = "square" ``` ---------------------------------------- TITLE: Configure diffedit3-ssh for SSH Usage DESCRIPTION: Uses diffedit3-ssh for diff editing over SSH, which avoids automatically opening a web browser and uses specific ports for communication. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_60 LANGUAGE: TOML CODE: ``` ui.diff-editor = "diffedit3-ssh" ``` ---------------------------------------- TITLE: Evaluate Revset at Operation DESCRIPTION: This function evaluates `x` at the specified operation. For example, `at_operation(@-, visible_heads())` will return all heads which were visible at the previous operation. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_62 LANGUAGE: none CODE: ``` at_operation(op, x) ``` ---------------------------------------- TITLE: Configure jj fix to run rustfmt DESCRIPTION: Sets up the jj configuration to automatically run rustfmt with the nightly toolchain for code formatting, targeting all Rust files. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/contributing.md#_snippet_6 LANGUAGE: Shell CODE: ``` jj config set --repo fix.tools.rustfmt '{ command = ["rustfmt", "+nightly"], patterns = ["glob:**/*.rs"] }' ``` ---------------------------------------- TITLE: Configure jj default list template DESCRIPTION: Sets the default template for 'jj config list'. It can use a built-in template or a detailed version that shows the origin of config variables. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_25 LANGUAGE: toml CODE: ``` [templates] # Use builtin config list template config_list = "builtin_config_list" ``` LANGUAGE: toml CODE: ``` [templates] config_list = "builtin_config_list_detailed" ``` ---------------------------------------- TITLE: jj log with Revset Filtering DESCRIPTION: Lists commits using a revset expression to select specific revisions. This example shows how to include the working-copy commit, the root commit, and commits pointed to by bookmarks, combined using union operators. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/tutorial.md#_snippet_10 LANGUAGE: shell CODE: ``` $ jj log -r '@ | root() | bookmarks()' @ mpqrykyp martinvonz@google.com 2023-02-12 15:00:22 aef4df99 │ (empty) (no description set) ~ (elided revisions) ◆ orrkosyo octocat@nowhere.com 2012-03-06 15:06:50 master 7fd1a60b │ (empty) Merge pull request #6 from Spaceghost/patch-1 ~ (elided revisions) ◆ zzzzzzzz root() 00000000 ``` ---------------------------------------- TITLE: Clone jj repository and create new version tag DESCRIPTION: This sequence of commands clones the jj repository into a temporary directory, navigates into it, and creates a new version tag using jj. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/releasing.md#_snippet_3 LANGUAGE: shell CODE: ``` cd $(mktemp -d) jj git clone https://github.com/jj-vcs/jj cd jj jj new v0..0 ``` ---------------------------------------- TITLE: Disable Abandoning Unreachable Commits DESCRIPTION: Disables the automatic abandonment of Git-unreachable commits when importing refs, preventing rebasing of descendant commits. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_95 LANGUAGE: toml CODE: ``` [git] abandon-unreachable-commits = false ``` ---------------------------------------- TITLE: Configure Same-Change Conflict Resolution DESCRIPTION: Determines how `jj` handles conflicts where all merging sides made the same change. 'accept' (default) resolves these automatically, while 'keep' leaves them unresolved. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_101 LANGUAGE: toml CODE: ``` [merge] same-change = "accept" ``` ---------------------------------------- TITLE: Describe a Jujutsu Change DESCRIPTION: Adds a description to the current working copy change in Jujutsu. This command opens the configured editor to allow the user to input a commit message. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/tutorial.md#_snippet_2 LANGUAGE: shell CODE: ``` # This brings up $EDITOR (or `nano` or `Notepad` by default). # Enter something like "Say goodbye" in the editor and then save the file and close # the editor. $ jj describe Working copy (@) now at: kntqzsqt e427edcf (empty) Say goodbye Parent commit (@-) : orrkosyo 7fd1a60b master | (empty) Merge pull request #6 from Spaceghost/patch-1 ``` ---------------------------------------- TITLE: Get Workspace Root Path with jj DESCRIPTION: Print the root path of the current workspace using the 'jj workspace root' command. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/working-copy.md#_snippet_9 LANGUAGE: bash CODE: ``` jj workspace root ``` ---------------------------------------- TITLE: Set Default Git Fetch Remote DESCRIPTION: Configures the default remote for 'jj git fetch' to 'upstream'. Supports single remotes or lists of remotes. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_89 LANGUAGE: sh CODE: ``` jj config set --repo git.fetch "upstream" ``` LANGUAGE: sh CODE: ``` jj config set --repo git.fetch '["origin", "upstream"]' ``` ---------------------------------------- TITLE: Set Diff Formatter DESCRIPTION: Specifies the formatter used for displaying diffs. Built-in options include ':color-words', ':git', ':summary', etc., or an external command can be used. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_15 LANGUAGE: toml CODE: ``` [ui] # Builtin formats: ":color-words" (default), ":git", # ":summary", ":stat", ":types", ":name-only" # or external command name and arguments (see below) diff-formatter = ":git" ``` ---------------------------------------- TITLE: Creating and managing remote bookmarks with jj DESCRIPTION: This section explains how `jj git push --allow-new` creates and tracks new remote bookmarks, and how to manage existing ones. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/bookmarks.md#_snippet_13 LANGUAGE: shell CODE: ``` jj git push --allow-new ``` ---------------------------------------- TITLE: Configure jj log word wrapping DESCRIPTION: Enables or disables word wrapping for log, evolog, and op log content based on terminal width in jj. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_31 LANGUAGE: toml CODE: ``` [ui] log-word-wrap = true ``` ---------------------------------------- TITLE: SSH Configuration for diffedit3 Port Forwarding DESCRIPTION: Configures SSH client settings to automatically forward necessary ports for diffedit3 when connecting to a remote host. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_62 LANGUAGE: ssh-config CODE: ``` Host myhost User myself Hostname myhost.example.com LocalForward 17376 localhost:17376 LocalForward 17377 localhost:17377 LocalForward 17378 localhost:17378 LocalForward 17379 localhost:17379 LocalForward 17380 localhost:17380 ``` ---------------------------------------- TITLE: Set Default Command DESCRIPTION: Configures the default command to run when 'jj' is executed without a subcommand. This can be any valid subcommand, alias, or user-defined alias. Defaults to 'log'. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_8 LANGUAGE: toml CODE: ``` [ui] default-command = ["log", "--reversed"] ``` ---------------------------------------- TITLE: Configure SSH Allowed Signers DESCRIPTION: Specifies the path to an 'allowed-signers' file for the SSH backend. This file lists the public keys of authors whose signatures jj should verify, enhancing security. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_84 LANGUAGE: toml CODE: ``` [signing] backends.ssh.allowed-signers = "/path/to/allowed-signers" ``` ---------------------------------------- TITLE: Console Example: Merging with Renames DESCRIPTION: This console output demonstrates a merge scenario involving a file rename. It illustrates how rebasing a commit with a rename operation affects the file's path across different versions. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/design/copy-tracking.md#_snippet_8 LANGUAGE: console CODE: ``` M set foo="bye" | | L rename foo->bar |/ K add foo="hello" ``` ---------------------------------------- TITLE: Set Git Fetch Remote using Patterns DESCRIPTION: Configures the default remote for 'jj git fetch' using string patterns like 'glob:*' or specific glob patterns. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_90 LANGUAGE: sh CODE: ``` jj config set --repo git.fetch "glob:*" ``` LANGUAGE: sh CODE: ``` jj config set --repo git.fetch '["glob:remote*", "glob:upstream*"]' ``` ---------------------------------------- TITLE: Format Author Signature DESCRIPTION: Customizes how author signatures are displayed. Options include showing the full email, name and email, or just the username part of the email. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_38 LANGUAGE: toml CODE: ``` [template-aliases] # Full email address (default) 'format_short_signature(signature)' = 'signature.email()' # Both name and email address 'format_short_signature(signature)' = 'signature' # Username part of the email address 'format_short_signature(signature)' = 'signature.email().local()' ``` ---------------------------------------- TITLE: Configure Pager and Diff Style with delta DESCRIPTION: This TOML configuration sets 'delta' as the pager and specifies ':git' for git-style diffs, which is required by some formatters like delta. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_47 LANGUAGE: toml CODE: ``` [ui] pager = "delta" diff-formatter = ":git" ``` ---------------------------------------- TITLE: Configure Automatically Tracked Paths DESCRIPTION: Sets patterns for which new files in the working copy should be automatically tracked by `jj`. Files matching ignore patterns are never tracked automatically. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_104 LANGUAGE: toml CODE: ``` [snapshot] auto-track = "glob:**" ``` ---------------------------------------- TITLE: Divergent Copy and Rename Example (Best Rename Target) DESCRIPTION: Demonstrates selecting the best rename target when diffing between commits L and N, considering file relationships and graph proximity. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/design/copy-tracking.md#_snippet_6 LANGUAGE: console CODE: ``` N copy baz->qux | M rename foo->baz | | L rename foo->bar |/ K add foo ``` ---------------------------------------- TITLE: Configure Biome CLI for workspace tools (Linux/macOS) DESCRIPTION: This configuration shows how to use a tool stored within the workspace, such as the Biome CLI, on Linux and macOS. It uses the '$root' variable to construct an absolute path to the executable. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_71 LANGUAGE: toml CODE: ``` [fix.tools.biome] # Linux and macOS command = ["$root/node_modules/@biomejs/cli-linux-x64/biome"] ``` ---------------------------------------- TITLE: Configure jj to use Vimdiff for diffing DESCRIPTION: This snippet demonstrates how to configure jj to use Vimdiff as a diff editor. While possible, using Vimdiff directly is not recommended for a better experience; custom plugins are suggested. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_65 LANGUAGE: TOML CODE: ``` [ui] diff-editor = "vimdiff" ``` ---------------------------------------- TITLE: Publish jj crates DESCRIPTION: These commands navigate into the respective crate directories within the jj project and publish each crate to crates.io using cargo publish. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/releasing.md#_snippet_4 LANGUAGE: shell CODE: ``` (cd lib/proc-macros && cargo publish) (cd lib && cargo publish) (cd cli && cargo publish) ``` ---------------------------------------- TITLE: Configure GVim as Diff Tool (DirDiff Plugin) DESCRIPTION: This bash script configures GVim as a diff tool using the DirDiff plugin. It includes the `--nofork` option to keep GVim running and allows for optional colorscheme settings. This is an alternative to the standard `vimdiff` setup. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/Vim,-Neovim.md#_snippet_1 LANGUAGE: bash CODE: ``` gvim --nofork "$@" -c "colorscheme murphy" -c "DirDiff $DIR1 $DIR2" ``` ---------------------------------------- TITLE: SizeHint Bounds DESCRIPTION: Provides methods to get the lower bound, optional upper bound, and optional exact value of a SizeHint. It also includes a method to check if the size hint is zero. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_40 LANGUAGE: jj CODE: ``` size_hint.lower() -> Integer size_hint.upper() -> Option size_hint.exact() -> Option size_hint.zero() -> Boolean ``` ---------------------------------------- TITLE: View Git-like Diffs in Jujutsu DESCRIPTION: This command displays the differences between the current version and the previous version of a file in a format similar to `git diff`. The `--git` flag is used for readability in tutorials, as Jujutsu's default inline coloring can be less clear in documentation. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/tutorial.md#_snippet_4 LANGUAGE: shell CODE: ``` $ jj diff --git # Feel free to skip the `--git` flag ``` LANGUAGE: git CODE: ``` diff --git a/README b/README index 980a0d5f19..1ce3f81130 100644 --- a/README +++ b/README @@ -1,1 +1,1 @@ -Hello World! +Goodbye World! ``` ---------------------------------------- TITLE: Configure Bookmark Listing Sort Order DESCRIPTION: Sets the sorting keys for the 'jj bookmark list' command. Supports keys like 'name', 'author-name', etc., with '-' for descending order. This configuration is ignored when the --sort option is used. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_12 LANGUAGE: toml CODE: ``` [ui] bookmark-list-sort-keys = ["name"] ``` ---------------------------------------- TITLE: Modify Protobuf Files and Regenerate Rust Code DESCRIPTION: This section details the process of modifying .proto files, which requires recompiling them into Rust code. It involves installing the protoc compiler, running a generation script, and updating file lists if new .proto files are added. The generated .rs files are included in the repository and checked by CI. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/contributing.md#_snippet_22 LANGUAGE: shell CODE: ``` apt-get install protobuf-compiler ``` LANGUAGE: shell CODE: ``` cargo run -p gen-protos ``` ---------------------------------------- TITLE: jj Conflict Output Example DESCRIPTION: Illustrates the output format when jj encounters a conflict in a file missing a terminating newline. It shows the conflict markers and the differing content from various sides. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/conflicts.md#_snippet_4 LANGUAGE: text CODE: ``` <<<<<<< Conflict 1 of 1 +++++++ Contents of side #1 (no terminating newline) grapefruit %%%%%%% Changes from base to side #2 (adds terminating newline) -grape +grape >>>>>>> Conflict 1 of 1 ends ``` ---------------------------------------- TITLE: Stage and View Working Copy Changes in Jujutsu DESCRIPTION: This snippet demonstrates how to stage changes using `sed` and then view the current status of the working copy in Jujutsu. It shows modified files and the current and parent commit details. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/tutorial.md#_snippet_3 LANGUAGE: shell CODE: ``` $ sed -i 's/Hello/Goodbye/' README $ jj st ``` LANGUAGE: shell CODE: ``` Working copy changes: M README Working copy (@) : kntqzsqt 5d39e19d Say goodbye Parent commit (@-): orrkosyo 7fd1a60b master | (empty) Merge pull request #6 from Spaceghost/patch-1 ``` ---------------------------------------- TITLE: Format Commit Timestamp DESCRIPTION: Configures jj to display the author's timestamp for commits instead of the committer's timestamp. The output is expected to be a timestamp for further formatting. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_39 LANGUAGE: toml CODE: ``` [template-aliases] 'commit_timestamp(commit)' = 'commit.author().timestamp()' ``` ---------------------------------------- TITLE: Resume Working on Earlier Change with Jujutsu DESCRIPTION: Demonstrates how to resume working on an earlier change using 'jj new' followed by 'jj squash', or alternatively using 'jj edit'. This is useful for picking up work from a previous commit. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/FAQ.md#_snippet_18 LANGUAGE: console CODE: ``` jj new jj squash jj edit ``` ---------------------------------------- TITLE: Configure clang-format for C/C++ files DESCRIPTION: This configuration sets up clang-format to format C and C++ files, including sorting include directives. It uses the '$path' substitution to pass the filename to clang-format, which is important for features like include sorting. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_69 LANGUAGE: toml CODE: ``` [fix.tools.clang-format] command = ["/usr/bin/clang-format", "--sort-includes", "--assume-filename=$path"] patterns = ["glob:'**/*.c'", "glob:'**/*.h'"] ``` ---------------------------------------- TITLE: Configure PKCS#12 Commit Signing DESCRIPTION: Sets up jj to use PKCS#12 certificates for signing commits via the 'gpgsm' backend. Similar to GPG signing, it allows specifying a key and defaults to the user's email if not explicitly set. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_79 LANGUAGE: toml CODE: ``` [signing] behavior = "own" backend = "gpgsm" ## You can set `key` to anything accepted by `gpgsm -u` ## If not set then defaults to the key associated with `user.email` # key = "4ED556E9729E000F" # key = "signing@example.com" ``` ---------------------------------------- TITLE: Execute Inline Bash Script Alias DESCRIPTION: Defines an alias 'my-inline-script' to execute a multi-line bash script using 'jj util exec'. The script prints messages and arguments. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_50 LANGUAGE: toml CODE: ``` [aliases] my-inline-script = ["util", "exec", "--", "bash", "-c", """ set -euo pipefail echo \"Look Ma, everything in one file!\" echo \"args: $@\" """, ""] ``` ---------------------------------------- TITLE: Rebasing with divergent renames DESCRIPTION: Demonstrates rebasing operations with different rename scenarios. The first example shows rebasing a rename onto a commit that adds a file, and the second shows rebasing a rename onto another rename. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/design/copy-tracking.md#_snippet_13 LANGUAGE: console CODE: ``` $ jj log C rename bar->baz | B rename foo->bar | A add foo $ jj rebase -r C -d A ``` LANGUAGE: console CODE: ``` $ jj log C rename foo->baz | | B rename foo->bar |/ A add foo $ jj rebase -r C -d B ``` ---------------------------------------- TITLE: jj Parallelize and Rebase Example DESCRIPTION: Shows how `jj parallelize` and subsequent rebases can maintain the integrity of file operations across a series of commits, ensuring that changes are applied correctly even after complex history manipulations. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/design/copy-tracking.md#_snippet_2 LANGUAGE: console CODE: ``` $ jj log E edit qux | D rename baz->qux | C rename bar->baz | B rename foo->bar | A add foo $ jj parallelize B::D # There should be no conflict in E and it should look like a # regular edit just like before $ jj rebase -r C -A B $ jj rebase -r D -A C # Now we're back to the same graph as before. ``` ---------------------------------------- TITLE: Ignore JJ VCS User Configurations DESCRIPTION: Runs a JJ VCS command while ignoring any user-specified configurations. This is achieved by setting the JJ_CONFIG environment variable to an empty value. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_108 LANGUAGE: bash CODE: ``` JJ_CONFIG= jj log # Ignores any settings specified in the config file. ``` ---------------------------------------- TITLE: Show All Commits with jj log DESCRIPTION: A command to display all commits in the repository, including those that might be omitted by default logging. It uses the revset '::' or 'all()' to ensure all reachable commits are shown. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/tutorial.md#_snippet_11 LANGUAGE: shell CODE: ``` jj log -r :: ``` LANGUAGE: shell CODE: ``` jj log -r 'all()' ``` ---------------------------------------- TITLE: Configure Pagination Behavior DESCRIPTION: Sets the pagination behavior for jj commands. Options include 'auto' for automatic pagination, 'never' to disable it, or other values that control when paging is used. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_42 LANGUAGE: toml CODE: ``` [ui] # Enable pagination for commands that support it (default) paginate = "auto" # Disable all pagination, equivalent to using --no-pager paginate = "never" ``` ---------------------------------------- TITLE: Jujutsu Template: Operation Keywords DESCRIPTION: In 'jj op log' templates, operation-specific keywords are available, representing 0-argument methods of the Operation type. For example, 'current_operation' is equivalent to 'self.current_operation()'. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_1 LANGUAGE: Jujutsu Template CODE: ``` current_operation ``` ---------------------------------------- TITLE: Clone Git Repository with jj DESCRIPTION: Clones a Git repository using the 'jj git clone' command. It fetches objects from the remote repository and sets up bookmarks for branches. Note that cloning native jj repos is not yet supported. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/tutorial.md#_snippet_0 LANGUAGE: shell CODE: ``` # Note the "git" before "clone" (there is no support for cloning native jj # repos yet) $ jj git clone https://github.com/octocat/Hello-World Fetching into new repo in "/tmp/tmp.O1DWMiaKd4/Hello-World" remote: Enumerating objects: 13, done. remote: Total 13 (delta 0), reused 0 (delta 0), pack-reused 13 (from 1) bookmark: master@origin [new] untracked bookmark: octocat-patch-1@origin [new] untracked bookmark: test@origin [new] untracked Setting the revset alias `trunk()` to `master@origin` Working copy (@) now at: kntqzsqt d7439b06 (empty) (no description set) Parent commit (@-) : orrkosyo 7fd1a60b master | (empty) Merge pull request #6 from Spaceghost/patch-1 Added 1 files, modified 0 files, removed 0 files $ cd Hello-World ``` ---------------------------------------- TITLE: Implement jj Policy in Codebase DESCRIPTION: This describes the typical implementation step for an approved proposal in the jj version control system, which involves merging the policy document into the codebase. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/governance/temporary-voting.md#_snippet_0 LANGUAGE: text CODE: ``` Typically, implementation will look like merging the document with the policy into the jj codebase and remembering to use that policy in conversations moving forward. ``` ---------------------------------------- TITLE: Configure GnuPG Commit Signing DESCRIPTION: Configures jj to use GnuPG for signing commits. It specifies the signing behavior and backend, with an option to set a specific GPG key. The default behavior is to use the key associated with the user's email. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_76 LANGUAGE: toml CODE: ``` [signing] behavior = "own" backend = "gpg" ## You can set `key` to anything accepted by `gpg -u` ## If not set then defaults to the key associated with `user.email` # key = "4ED556E9729E000F" # key = "signing@example.com" ``` ---------------------------------------- TITLE: Rebase Commits with jj DESCRIPTION: Illustrates how to rebase a commit ('B2') and its descendants ('C') onto another commit ('A') using `jj rebase -s` and `-d`. This example also shows how conflicts can arise when the rebased commits modify the same file. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/tutorial.md#_snippet_13 LANGUAGE: shell CODE: ``` $ jj rebase -s puqltutt -d nuvyytnq # Replace the IDs by what you have for B2 and A Rebased 2 commits to destination Working copy (@) now at: qzvqqupx 1978b534 (conflict) C Parent commit (@-) : puqltutt f7fb5943 (conflict) B2 Added 0 files, modified 1 files, removed 0 files Warning: There are unresolved conflicts at these paths: file1 2-sided conflict New conflicts appeared in 2 commits: qzvqqupx 1978b534 (conflict) C puqltutt f7fb5943 (conflict) B2 Hint: To resolve the conflicts, start by creating a commit on top of the first conflicted commit: jj new puqltutt Then use `jj resolve`, or edit the conflict markers in the file directly. Once the conflicts are resolved, you can inspect the result with `jj diff`. Then run `jj squash` to move the resolution into the conflicted commit. $ jj log @ qzvqqupx martinvonz@google.com 2023-02-12 15:08:33 1978b534 conflict │ C × puqltutt martinvonz@google.com 2023-02-12 15:08:33 f7fb5943 conflict │ B2 │ ○ ovknlmro martinvonz@google.com 2023-02-12 15:07:24 7d7c6e6b ├─╯ B1 ○ nuvyytnq martinvonz@google.com 2023-02-12 15:07:05 5dda2f09 │ A │ ○ kntqzsqt martinvonz@google.com 2023-02-12 14:56:59 5d39e19d ├─╯ Say goodbye ◆ orrkosyo octocat@nowhere.com 2012-03-06 15:06:50 master 7fd1a60b │ (empty) Merge pull request #6 from Spaceghost/patch-1 ~ ``` ---------------------------------------- TITLE: Configure Merge Hunk Granularity DESCRIPTION: Sets the granularity for resolving content conflicts during merges. Options include 'line' (default) for line-level hunks and 'word' for finer, word-level hunks. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_100 LANGUAGE: toml CODE: ``` [merge] hunk-level = "line" ``` ---------------------------------------- TITLE: Configure jj fix for Nix/direnv users DESCRIPTION: Configures jj's fix command to use rustfmt, specifically for users of Nix and direnv, assuming a nightly toolchain is already available in the environment. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/contributing.md#_snippet_7 LANGUAGE: Shell CODE: ``` jj config set --repo fix.tools.rustfmt '{ command = ["rustfmt"], patterns = ["glob:**/*.rs"] }' ``` ---------------------------------------- TITLE: Configure Git Diff Options DESCRIPTION: Sets the number of context lines to display in git diffs. This option allows customization of how much surrounding code is shown alongside changes in git-formatted diffs. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_17 LANGUAGE: TOML CODE: ``` [diff.git] context = 3 ``` ---------------------------------------- TITLE: Divergent Copy and Rename Example DESCRIPTION: Illustrates a scenario with divergent copy and rename operations across commits K, L, and M. It shows the resulting file trees and the relationships between copy IDs, explaining how jj determines diffs based on these relationships. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/design/copy-tracking.md#_snippet_4 LANGUAGE: console CODE: ``` M rename foo->baz, create bar | | L copy foo->bar, create baz |/ K add foo ``` LANGUAGE: console CODE: ``` Commit K: name: foo, id: K, copy_id: 1:foo Commit L: name: bar, id: L, copy_id: 2:bar->1:foo name: baz, id: L, copy_id: 3:baz name: foo, id: K, copy_id: 1:foo Commit M: name: bar, id: M, copy_id: 4:bar name: baz, id: M, copy_id: 5:baz->1:foo ``` ---------------------------------------- TITLE: Monitoring jj log Evolution with watch DESCRIPTION: Shows how to use the `watch` command to continuously monitor the output of `jj log`. This helps in observing changes to the repository's history in real-time. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/FAQ.md#_snippet_1 LANGUAGE: sh CODE: ``` watch --color jj --ignore-working-copy log --color=always ``` ---------------------------------------- TITLE: jj op log -T 'self.id().short()' DESCRIPTION: Example of using the 'jj op log' command with a template to display the short ID of an operation. This demonstrates the use of labels for customizing output. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_42 LANGUAGE: sh CODE: ``` jj op log -T 'self.id().short()' ``` ---------------------------------------- TITLE: Configure jj to use Kdiff3 for 3-way merge DESCRIPTION: This TOML configuration sets Kdiff3 as the merge tool for jj. It defines the program to use and the specific command-line arguments, including placeholders for the base, left, right, and output files. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_67 LANGUAGE: TOML CODE: ``` [merge-tools.kdiff3] # program = "kdiff3" # Defaults to the name of the tool if not specified merge-args = ["$base", "$left", "$right", "-o", "$output", "--auto"] ``` ---------------------------------------- TITLE: Disable Rustfmt Tool DESCRIPTION: Demonstrates how to disable the rustfmt tool in the user configuration by setting 'enabled' to false. This prevents rustfmt from running globally, allowing it to be enabled selectively for specific repositories. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_74 LANGUAGE: toml CODE: ``` [fix.tools.rustfmt] enabled = false command = ["rustfmt", "--emit", "stdout"] patterns = ["glob:'**/*.rs'"] ``` ---------------------------------------- TITLE: Performance Tip: Using a minimal shell (Diff) DESCRIPTION: Demonstrates how to configure Starship to use a minimal shell for custom modules to potentially improve performance by avoiding shell initialization sourcing. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/Starship.md#_snippet_3 LANGUAGE: diff CODE: ``` + shell = ["sh", "--norc", "--noprofile"] ``` ---------------------------------------- TITLE: Jujutsu Template: Commit Keywords DESCRIPTION: In 'jj log' templates, commit-specific keywords are available, representing 0-argument methods of the Commit type. For example, 'commit_id' is equivalent to 'self.commit_id()'. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_0 LANGUAGE: Jujutsu Template CODE: ``` commit_id ``` ---------------------------------------- TITLE: Customize Draft Commit Description Template DESCRIPTION: Defines a template for populating the editor content of a commit description. It uses various functions like 'concat', 'coalesce', 'surround', 'indent', and 'diff.stat' to construct the description. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_9 LANGUAGE: toml CODE: ``` [templates] draft_commit_description = ''' concat( coalesce(description, default_commit_description, "\n"), surround( "\nJJ: This commit contains the following changes:\n", "", indent("JJ: ", diff.stat(72)), ), "\nJJ: ignore-rest\n", diff.git(), ) ''' ``` ---------------------------------------- TITLE: Get Latest Commits DESCRIPTION: This function retrieves the latest 'count' commits from a given revset 'x', ordered by committer timestamp. If 'count' is not specified, it defaults to 1. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_39 LANGUAGE: none CODE: ``` latest(x, [count]) ``` ---------------------------------------- TITLE: Configure SSH Revocation List DESCRIPTION: Sets the path to a revocation list file for the SSH backend. Signatures from public keys present in this file will be marked as invalid, allowing for the revocation of trust. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_85 LANGUAGE: toml CODE: ``` [signing] backends.ssh.revocation-list = "/path/to/revocation-list" ``` ---------------------------------------- TITLE: Configure External Diff Tool Arguments DESCRIPTION: Defines the arguments for an external diff tool specified by its name. This configuration allows customization of how the tool is invoked, including the use of placeholders like '$left' and '$right' for file paths. It also handles cases where no arguments are needed or where the tool should not be used for diffs. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_19 LANGUAGE: TOML CODE: ``` [merge-tools.] # program = "" # Defaults to the name of the tool if not specified diff-args = ["--color=always", "$left", "$right"] ``` ---------------------------------------- TITLE: Customize Diff Token Colors and Styles DESCRIPTION: Allows overriding the default styles for diff rendering, such as highlighting removed or added tokens with specific background colors or disabling underlines. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_14 LANGUAGE: toml CODE: ``` [colors] # Highlight hunks with background "diff removed token" = { bg = "#221111", underline = false } "diff added token" = { bg = "#002200", underline = false } # Alternatively, swap colors "diff token" = { reverse = true, underline = false } ``` ---------------------------------------- TITLE: Set Built-in Pager DESCRIPTION: Configures jj to use its built-in pager by setting the `ui.pager` configuration option to `:builtin`. This is an alternative to using the system's PAGER environment variable. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_41 LANGUAGE: shell CODE: ``` jj config set --user ui.pager :builtin ``` ---------------------------------------- TITLE: Conditional Configuration with Scope Tables DESCRIPTION: Illustrates using conditional variables with the --when flag and [[--scope]] tables. This allows specific configurations to be enabled based on conditions like the repository path or the command being executed. Variables within scope tables are expanded to the root table. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_112 LANGUAGE: toml CODE: ``` [user] name = "YOUR NAME" email = "YOUR_DEFAULT_EMAIL@example.com" # override user.email if the repository is located under ~/oss [[--scope]] --when.repositories = ["~/oss"] [--scope.user] email = "YOUR_OSS_EMAIL@workplace.com" # disable pagination for `jj status`, use `delta` for `jj diff` and `jj show` [[--scope]] --when.commands = ["status"] [--scope.ui] paginate = "never" [[--scope]] --when.commands = ["diff", "show"] [--scope.ui] pager = "delta" ``` ---------------------------------------- TITLE: Configure jj to use Meld for diffing DESCRIPTION: This snippet shows how to configure jj to use Meld as a diff editor. Meld is a graphical diff tool that can be used for both 2-pane and 3-pane diff views. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_64 LANGUAGE: TOML CODE: ``` [ui] diff-editor = "meld" ``` ---------------------------------------- TITLE: Build Systems Integration with JJ run DESCRIPTION: Illustrates how 'jj run' can be utilized to interact with build systems such as Bazel and Ninja, enabling tasks like building targets or running checks. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/design/run.md#_snippet_2 LANGUAGE: shell CODE: ``` jj run 'bazel build //some/target:somewhere' jj run 'ninja check-lld' ``` ---------------------------------------- TITLE: Customize jj operation ID display format DESCRIPTION: Customizes the display format for operation IDs in jj using the 'format_short_operation_id()' template alias, such as always showing a fixed length. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_33 LANGUAGE: toml CODE: ``` [template-aliases] # Always show 12 characters 'format_short_operation_id(id)' = 'id.short(12)' ``` ---------------------------------------- TITLE: Configure jj to use Meld for 3-way merge DESCRIPTION: This configuration sets Meld as the merge editor for jj's conflict resolution. It specifies the command-line arguments for Meld, including placeholders for input files and the output file. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_66 LANGUAGE: TOML CODE: ``` [ui] merge-editor = "meld" # Or specify merge-args inline merge-editor = ["meld", "$left", "$base", "$right", "-o", "$output"] ``` ---------------------------------------- TITLE: Use mold linker with cargo insta test DESCRIPTION: This command uses the 'mold' linker to potentially speed up the execution of 'cargo insta test' on Linux by utilizing multi-threaded linking. It's a way to leverage 'mold' for faster test binary linking. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/contributing.md#_snippet_8 LANGUAGE: shell CODE: ``` mold -run cargo insta test --workspace --test-runner nextest ``` ---------------------------------------- TITLE: Disable Default Bookmark Tracking on Clone DESCRIPTION: Disables the default behavior of creating a local bookmark that tracks the default remote bookmark (e.g., 'main@origin') when cloning a Git repository. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_94 LANGUAGE: toml CODE: ``` [git] track-default-bookmark-on-clone = false ``` ---------------------------------------- TITLE: List Operations DESCRIPTION: Offers various utility methods for manipulating lists, including getting the length, joining elements with a separator, filtering, mapping, and checking for any or all elements satisfying a condition. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_32 LANGUAGE: Rust CODE: ``` list.len() list.join(separator) list.filter(|item| expression) list.map(|item| expression) list.any(|item| expression) list.all(|item| expression) ``` ---------------------------------------- TITLE: Customize jj relative timestamp format DESCRIPTION: Customizes the display format for timestamps in jj using the 'format_timestamp()' template alias, such as displaying the full timestamp in ISO 8601 format. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_35 LANGUAGE: toml CODE: ``` [template-aliases] # Full timestamp in ISO 8601 format 'format_timestamp(timestamp)' = 'timestamp' ``` ---------------------------------------- TITLE: View Operation Log with jj op log DESCRIPTION: Lists the history of operations performed on the repository. Each entry includes an operation hash, author, timestamp, duration, a description of the operation, and the arguments used. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/tutorial.md#_snippet_17 LANGUAGE: shell CODE: ``` $ jj op log @ d3b77addea49 martinvonz@vonz.svl.corp.google.com 3 minutes ago, lasted 3 milliseconds │ squash commits into f7fb5943a6b9460eb106dba2fac5cac1625c6f7a │ args: jj squash ○ 6fc1873c1180 martinvonz@vonz.svl.corp.google.com 3 minutes ago, lasted 1 milliseconds │ snapshot working copy │ args: jj st ○ ed91f7bcc1fb martinvonz@vonz.svl.corp.google.com 6 minutes ago, lasted 1 milliseconds │ new empty commit │ args: jj new puqltutt ○ 367400773f87 martinvonz@vonz.svl.corp.google.com 12 minutes ago, lasted 3 milliseconds │ rebase commit daa6ffd5a09a8a7d09a65796194e69b7ed0a566d and descendants │ args: jj rebase -s puqltutt -d nuvyytnq [many more lines] ``` ---------------------------------------- TITLE: Format Timestamp Relative DESCRIPTION: Configures the relative timestamp format for displaying time differences (e.g., 'x days ago'). This is often used in command outputs like `jj op log`. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_36 LANGUAGE: toml CODE: ``` [template-aliases] 'format_timestamp(timestamp)' = 'timestamp.ago()' ``` ---------------------------------------- TITLE: Configure SSH Commit Signing DESCRIPTION: Sets up jj to sign commits using SSH keys. It requires specifying the SSH public key directly or via a file path. The 'behavior' setting controls when commits are signed. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_82 LANGUAGE: toml CODE: ``` [signing] behavior = "own" backend = "ssh" key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGj+J6N6SO+4P8dOZqfR1oiay2yxhhHnagH52avUqw5h" ## You can also use a path instead of embedding the key # key = "~/.ssh/id_for_signing.pub" ``` ---------------------------------------- TITLE: Sign Commits Automatically on Modification DESCRIPTION: Explains the 'signing.behavior' configuration option, which controls automatic commit signing upon modification. Options include 'drop', 'keep', 'own', and 'force', determining how existing or new signatures are handled. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_86 LANGUAGE: toml CODE: ``` ## Automatically signing commits The `signing.behavior` configuration option has four different options for what to do with signing commits on modification of a change (e.g., rebasing or edits). - `drop`: do not automatically sign; if a change was signed before modification, drop that signing after modification. - `keep`: if a change was signed before modification, and it was authored by you, attempt to sign it again after the modification. - `own`: sign all commits that were authored by you when you modify them. - `force`: sign all commits after modification, always, even if you are not the author. Instead of signing all commits during creation when `signing.behavior` is set to `own`, the `git.sign-on-push` configuration can be used to sign commits only upon running `jj git push`. All mutable unsigned commits being pushed will be signed prior to pushing. This might be preferred if the signing backend requires user interaction or is slow, so that signing is performed in a single batch operation. ```toml [signing] behavior = "own" ``` ``` ---------------------------------------- TITLE: Profile JJ with JJ_TRACE and Perfetto DESCRIPTION: Alternatively, JJ's manually added instrumentation can be used for profiling via the JJ_TRACE environment variable, which outputs a trace file. This file can then be visualized using Perfetto UI in Chrome. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/contributing.md#_snippet_25 LANGUAGE: shell CODE: ``` JJ_TRACE=/tmp/trace.json jj diff ``` ---------------------------------------- TITLE: Configure Pager Wrapping DESCRIPTION: Defines how lines are wrapped within the jj built-in pager. Options include wrapping at the screen edge, on word boundaries, or disabling wrapping to allow horizontal scrolling. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_43 LANGUAGE: toml CODE: ``` [ui.streampager] wrapping = "anywhere" # wrap at screen edge (default) wrapping = "word" # wrap on word boundaries wrapping = "none" # strip long lines, allow scrolling # left and right like `less -S` ``` ---------------------------------------- TITLE: Run Demo Scripts and Generate Screenshots DESCRIPTION: Executes all demo scripts in the 'demos' directory and pipes the output to 'less' for viewing. This command is used to run the demo scripts and potentially generate associated screenshots. SOURCE: https://github.com/jj-vcs/jj/blob/main/demos/README.md#_snippet_0 LANGUAGE: shell CODE: ``` cd demos ./run_scripts.sh demo_*.sh |less ``` ---------------------------------------- TITLE: Enable JJ VCS TOML Schema Validation DESCRIPTION: Enables schema validation for JJ VCS TOML configuration files by adding a schema directive at the top of the file. This provides features like autocompletion, type checking, and documentation in supported editors. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_109 LANGUAGE: toml CODE: ``` #:schema https://jj-vcs.github.io/jj/latest/config-schema.json ``` ---------------------------------------- TITLE: Configure jj prev/next --edit flag default DESCRIPTION: Sets the '--edit' flag as the default for 'prev' and 'next' commands in jj. This enables an edit-based workflow by default. Use '--no-edit' to revert to the original behavior. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_24 LANGUAGE: toml CODE: ``` [ui.movement] edit = true ``` ---------------------------------------- TITLE: Set Maximum Size for New Files DESCRIPTION: Defines the maximum size for new files that `jj` will add to a snapshot, acting as an anti-footgun measure. The limit can be specified in bytes or with human-readable suffixes (e.g., '10MiB'). Setting to zero disables the limit. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_105 LANGUAGE: toml CODE: ``` [snapshot] max-new-file-size = "10MiB" ``` LANGUAGE: toml CODE: ``` [snapshot] max-new-file-size = 10485760 ``` ---------------------------------------- TITLE: jj Command Options DESCRIPTION: Lists common command-line options for jj commands, including flags for parallelism, failure handling, and execution control. Some options are noted as aliases for compatibility or specific functionalities. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/design/run.md#_snippet_3 LANGUAGE: bash CODE: ``` * --command, explicit name of the first argument * -x, for git compatibility (may alias another command) * -j, --jobs, the amount of parallelism to use * -k, --keep-going, continue on failure (may alias another command) * --show, display the diff for an affected revision * --dry-run, do the command execution without doing any work, logging all intended files and arguments * --rebase, rebase all parents on the consulitng diff (may alias another command) * --reparent, change the parent of an effected revision to the new change (may alias another command) * --clean, remove existing workspaces and remove the ignored files * --readonly, ignore changes across multiple run invocations * --error-strategy=`continue|stop|fatal`, see [Dealing with failure](#dealing-with-failure) ``` ---------------------------------------- TITLE: Customize jj log node symbols via templates DESCRIPTION: Customizes the symbols used for commits and operations in the jj log. It defines templates for 'log_node' and 'op_log_node' to represent different commit states. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_30 LANGUAGE: toml CODE: ``` [templates] log_node = ''' coalesce( if(!self, "🮀"), if(current_working_copy, "@"), if(root, "┴"), if(immutable, "●", "○"), ) ''' op_log_node = 'if(current_operation, "@", "○")' ``` ---------------------------------------- TITLE: Allow Expired GPG Keys DESCRIPTION: Configures the gpg backend to consider expired GPG keys as valid during commit signature verification. This can be useful in environments where key rotation is frequent or for testing purposes. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_78 LANGUAGE: toml CODE: ``` [signing] backends.gpg.allow-expired-keys = true ``` ---------------------------------------- TITLE: Divergent Copy and Rename Graph DESCRIPTION: A Mermaid graph visualizing the commit history and copy ID relationships for the divergent copy and rename example involving commits K, L, and M. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/design/copy-tracking.md#_snippet_5 LANGUAGE: mermaid CODE: ``` graph LR subgraph L["Commit L"] 2["2:bar"] 3["3:baz"] subgraph K["Commit K"] 1["1:foo"] end end subgraph M["Commit M"] 4["4:bar"] 5["5:baz"] end 2 --> 1 5 --> 1 ``` ---------------------------------------- TITLE: Performance Tip: Using detect_folders (Diff) DESCRIPTION: Shows how to modify the Starship configuration to use `detect_folders` instead of a shell command for detecting jj repositories, potentially improving performance by avoiding shell invocation overhead. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/Starship.md#_snippet_2 LANGUAGE: diff CODE: ``` - when = "jj --ignore-working-copy root" + detect_folders = [".jj"] ``` ---------------------------------------- TITLE: Interactive Rebase with jj rebase DESCRIPTION: Jujutsu's `jj rebase` command can be used for interactive reordering of commits. For example, to move commit `C` before `B` in a linear chain `A` to `C`, use `jj rebase -r C -B B`. Use `jj squash` and `jj split` for squashing or splitting commits. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/FAQ.md#_snippet_6 LANGUAGE: jj CODE: ``` jj rebase -r C -B B jj squash jj split ``` ---------------------------------------- TITLE: String Manipulation Methods DESCRIPTION: Offers a comprehensive set of methods for string manipulation, including getting length, checking for substrings, pattern matching, line splitting, case conversion, prefix/suffix removal, trimming, substring extraction, and JSON escaping. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_41 LANGUAGE: jj CODE: ``` string.len() -> Integer string.contains(needle: Stringify) -> Boolean string.match(needle: StringPattern) -> String string.first_line() -> String string.lines() -> List string.upper() -> String string.lower() -> String string.starts_with(needle: Stringify) -> Boolean string.ends_with(needle: Stringify) -> Boolean string.remove_prefix(needle: Stringify) -> String string.remove_suffix(needle: Stringify) -> String string.trim() -> String string.trim_start() -> String string.trim_end() -> String string.substr(start: Integer, end: Integer) -> String string.escape_json() -> String ``` ---------------------------------------- TITLE: Configure External Diff Formatter DESCRIPTION: Specifies an external command to be used for generating diffs when a builtin format is not sufficient. This allows integration with tools like 'difft' or custom scripts, defining the command and its arguments, including placeholders for left and right file paths. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_18 LANGUAGE: TOML CODE: ``` [ui] # Use Difftastic by default diff-formatter = ["difft", "--color=always", "$left", "$right"] # Use tool named "" (see below) diff-formatter = "" ``` ---------------------------------------- TITLE: Helix Editor Rustfmt Configuration DESCRIPTION: Configuration for the Helix editor to set up the 'rustfmt' language server with specific arguments. This allows using the nightly version of 'rustfmt' for formatting Rust code. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/contributing.md#_snippet_11 LANGUAGE: toml CODE: ``` # .helix/languages.toml [language-server.rust-analyzer.config.rustfmt] extraArgs = ["+nightly"] ``` ---------------------------------------- TITLE: Configure IntelliJ IDEA as jj Merge Tool (TOML) DESCRIPTION: This TOML configuration sets up IntelliJ IDEA (Community Edition or Ultimate) as a merge tool for jj. It specifies the command to launch IDEA and the arguments for diff, edit, and merge operations, including placeholders for left, right, base, and output files. The 'program' path may need adjustment based on your operating system and installation. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/JetBrains-IDEs.md#_snippet_0 LANGUAGE: toml CODE: ``` [merge-tools.idea] # Likely needs to be adjusted, see below program = "idea.sh" # Linux program = "/Applications/IntelliJ IDEA CE.app/Contents/MacOS/idea" # MacOS diff-args = ["diff", "$left", "$right"] edit-args = ["diff", "$left", "$right"] merge-args = ["merge" , "$left", "$right", "$base", "$output"] ``` ---------------------------------------- TITLE: Configure Diff Invocation Mode DESCRIPTION: Sets how external diff tools are invoked, either by providing a directory with left and right sides or by invoking file-by-file. This configuration affects how diff tools that expect individual files are handled. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_20 LANGUAGE: TOML CODE: ``` [ui] diff-formatter = "vimdiff" [merge-tools.vimdiff] diff-invocation-mode = "file-by-file" ``` ---------------------------------------- TITLE: Configure Pager Interface Behavior DESCRIPTION: Controls the pager's screen behavior, such as clearing the screen on startup/exit and automatically quitting for short inputs. Options affect whether a full-screen interface is used or if it quits quickly. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_44 LANGUAGE: toml CODE: ``` [ui.streampager] # Do not clear screen on exit. Use a full-screen interface for long # output only. Like `less -FX`. interface = "quit-if-one-page" # (default). # Always use a full-screen interface, ask the terminal to clear the # screen on exit. Like `less -+FX`. interface = "full-screen-clear-output" # Use the alternate screen if the input is either long or takes more # than 2 seconds to finish. Similar but not identical to `less -F -+X`. interface = "quit-quickly-or-clear-output" ``` ---------------------------------------- TITLE: Configure Beyond Compare for jj (Windows) DESCRIPTION: Provides Beyond Compare merge tool configurations for jj on Windows. It uses 'bcomp' as the program and employs Windows-style command-line arguments (e.g., '/blah' instead of '-blah') for read-only, expansion, and conflict resolution. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/Beyond-Compare.md#_snippet_1 LANGUAGE: toml CODE: ``` [merge-tools.bc] program = "bcomp" # You may need to provide a full path to BComp.exe edit-args = ["$left", "$right", "/leftreadonly", "/expandall"] merge-args = ["$left", "$right", "$base", "$output", "/automerge", "/reviewconflicts"] [merge-tools.bc-3] program = "bcomp" # You may need to provide a full path to BComp.exe edit-args = ["$left", "$right", "/expandall", "/mergeoutput=$right", "/leftreadonly", "/rightreadonly"] ``` ---------------------------------------- TITLE: Configure jj to use Vimdiff for 3-way merge DESCRIPTION: This configuration sets Vimdiff as the merge tool for jj, specifying the program and detailed merge arguments. It also includes a flag indicating that Vimdiff edits conflict markers. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_68 LANGUAGE: TOML CODE: ``` [merge-tools.vimdiff] merge-args = ["-f", "-d", "$output", "-M", "$left", "$base", "$right", "-c", "wincmd J", "-c", "set modifiable", "-c", "set write"] program = "vim" merge-tool-edits-conflict-markers = true # See below for an explanation ``` ---------------------------------------- TITLE: Allow Expired GPGsm Keys DESCRIPTION: Configures the gpgsm backend to treat expired PKCS#12 certificates as valid when verifying commit signatures. This setting is analogous to the GPG backend's expired key handling. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_81 LANGUAGE: toml CODE: ``` [signing] backends.gpgsm.allow-expired-keys = true ``` ---------------------------------------- TITLE: jj Function: children() DESCRIPTION: The children() function returns the children of a given commit. It can optionally take a depth argument to traverse multiple child generations. For example, children(x, 3) is equivalent to x+++. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_18 LANGUAGE: jj CODE: ``` children(x) children(x, depth) ``` ---------------------------------------- TITLE: Configure Conflict Marker Style DESCRIPTION: Sets the style of conflict markers used when materializing conflicts. Options include 'diff' for a single snapshot with diffs, 'snapshot' for individual side snapshots, and 'git' for Git's 'diff3' markers, which is useful for compatibility with tools that rely on this format. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_22 LANGUAGE: TOML CODE: ``` [ui] # Shows a single snapshot and one or more diffs to apply to it conflict-marker-style = "diff" # Shows a snapshot for each side and base of the conflict conflict-marker-style = "snapshot" # Uses Git's "diff3" conflict markers to support tools that depend on it conflict-marker-style = "git" ``` ---------------------------------------- TITLE: Configure Color-Words Diff Options DESCRIPTION: Sets the maximum number of alternations for inline diffs and the number of context lines for color-words diffs. The `max-inline-alternation` parameter controls when to switch from inline word diffs to traditional line diffs, with options ranging from disabling inlining to inlining all lines. The `context` parameter defines the number of surrounding lines to display. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_16 LANGUAGE: TOML CODE: ``` [diff.color-words] max-inline-alternation = 3 context = 3 ``` ---------------------------------------- TITLE: Initialize Jujutsu Repo with Git Backend DESCRIPTION: Creates an empty Jujutsu repository that uses a regular Git repository for storing commits. This allows collaboration with standard Git users. The underlying Git repository is located within the `.jj/repo/store/git/` directory. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/git-compatibility.md#_snippet_0 LANGUAGE: bash CODE: ``` jj init --git ``` ---------------------------------------- TITLE: jj Function: parents() DESCRIPTION: The parents() function returns the parents of a given commit. It can optionally take a depth argument to traverse multiple parent generations. For example, parents(x, 3) is equivalent to x---. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_17 LANGUAGE: jj CODE: ``` parents(x) parents(x, depth) ``` ---------------------------------------- TITLE: Sparse Pattern CLI Syntax DESCRIPTION: Defines the command-line interface syntax for specifying sparse pattern rules. It outlines the format for include/exclude, directory/files/exact matching, and path specification. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/design/sparse-v2.md#_snippet_2 LANGUAGE: txt CODE: ``` (include|exclude):(dir|files|exact): If both prefix terms are omitted, then `include:dir:` is assumed. If any prefix is specified, both must be specified. ``` ---------------------------------------- TITLE: Set Private Commits for Git Push DESCRIPTION: Configures a revset for `git.private-commits` to prevent specific commits (e.g., those with descriptions matching 'wip:*' or 'private:*') from being pushed. Commits already on the remote or immutable commits are excluded from this restriction. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_98 LANGUAGE: toml CODE: ``` [git] private-commits = "description(glob:'wip:*') | description(glob:'private:*')" ``` ---------------------------------------- TITLE: Basic jj Prompt Configuration (TOML) DESCRIPTION: Configures a basic Starship prompt to display jj repository status, including bookmarks, tags, and description. It uses `jj log` with specific formatting and a condition to check if the current directory is a jj repository root. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/Starship.md#_snippet_0 LANGUAGE: toml CODE: ``` [custom.jj] command = ''' jj log --revisions @ --limit 1 --ignore-working-copy --no-graph --color always --template ' separate(" ", bookmarks.map(|x| truncate_end(10, x.name(), "…")).join(" "), tags.map(|x| truncate_end(10, x.name(), "…")).join(" "), surround("\"", "\"", truncate_end(24, description.first_line(), "…")), if(conflict, "conflict"), if(divergent, "divergent"), if(hidden, "hidden"), ) ' ''' when = "jj --ignore-working-copy root" symbol = "jj" [custom.jjstate] when = "jj --ignore-working-copy root" command = ''' jj log -r@ -n1 --ignore-working-copy --no-graph -T "" --stat | tail -n1 | sd "(\d+) files? changed, (\d+) insertions?\(\+\), (\d+) deletions?(-)" ' ${1}m ${2}+ ${3}-' | sd " 0." "" ''' ``` ---------------------------------------- TITLE: Configure JJ VCS EOL Conversion DESCRIPTION: Sets the End-of-Line (EOL) conversion behavior for files in JJ VCS, analogous to Git's core.autocrlf setting. Options include 'none', 'input', and 'input-output' to manage line ending styles during file operations. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_106 LANGUAGE: toml CODE: ``` [working-copy] # No EOL conversion. Similar to core.autocrlf = false. eol-conversion = "none" # Apply CRLF to LF EOL conversion when we check files in the backend store from # the local file system but not apply EOL conversion when we check out the code # from the backend store to the local file system. Similar to core.autocrlf = # input. eol-conversion = "input" # Setting this to "input-output" if you want to have CRLF line endings in your # working directory and the repository has LF line endings. Similar to # core.autocrlf = true. eol-conversion = "input-output" ``` ---------------------------------------- TITLE: Basic jj log DESCRIPTION: Displays the commit history in the Jujutsu repository. The output shows the working-copy commit, change ID, commit ID, author, date, and commit message. The '~' symbol indicates commits with parents not included in the graph. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/tutorial.md#_snippet_9 LANGUAGE: shell CODE: ``` $ jj log @ mpqrykyp martinvonz@google.com 2023-02-12 15:00:22 aef4df99 │ (empty) (no description set) ○ kntqzsqt martinvonz@google.com 2023-02-12 14:56:59 5d39e19d │ Say goodbye ◆ orrkosyo octocat@nowhere.com 2012-03-06 15:06:50 master 7fd1a60b │ (empty) Merge pull request #6 from Spaceghost/patch-1 ~ ``` ---------------------------------------- TITLE: Define Custom Template Aliases in TOML DESCRIPTION: Defines custom template aliases in TOML format for jj. These aliases can combine predefined keywords and functions to create new formatting rules. The example shows how to define aliases for commit IDs and a generic field formatter. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_53 LANGUAGE: toml CODE: ``` [template-aliases] 'commit_change_ids' = ''' concat( format_field("Commit ID", commit_id), format_field("Change ID", change_id), ) ''' 'format_field(key, value)' = 'key ++ ": " ++ value ++ "\n"' ``` ---------------------------------------- TITLE: JJ Configuration for Git Fetch and Push DESCRIPTION: Illustrates how to configure the default Git remotes for fetching and pushing within Jujutsu by modifying the `config.toml` file. It covers setting a single default remote and multiple remotes for fetching. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/github.md#_snippet_11 LANGUAGE: toml CODE: ``` [git] fetch = "upstream" push = "origin" ``` LANGUAGE: toml CODE: ``` [git] fetch = ["upstream", "origin"] push = "origin" ``` ---------------------------------------- TITLE: Jujutsu: Commit in Colocated Git Repo DESCRIPTION: Demonstrates committing changes in a Git colocated repository after initializing with 'jj git init'. It shows updating the tutorial, committing, creating a bookmark, and pushing. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/github.md#_snippet_3 LANGUAGE: shell CODE: ``` $ nvim docs/tutorial.md $ jj commit -m "Update tutorial" $ jj bookmark create doc-update -r @- $ jj git push --allow-new ``` ---------------------------------------- TITLE: Resolve Symbol as Commit ID - Jujutsu DESCRIPTION: To override the default symbol resolution priority, use the appropriate revset function. For example, to resolve `abc` as a commit ID even if a bookmark with the same name exists, use `commit_id(abc)`. This is useful in scripts. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_2 LANGUAGE: bash CODE: ``` commit_id(abc) ``` ---------------------------------------- TITLE: Log with Quoted Symbol - Jujutsu DESCRIPTION: Use single or double quotes to prevent a symbol from being interpreted as an expression. For example, to refer to the symbol `x-`, you might need to use `jj log -r '"x-"'` to account for shell quoting. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_1 LANGUAGE: bash CODE: ``` jj log -r '"x-"' ``` ---------------------------------------- TITLE: View Log at Specific Operation with jj log --at-op DESCRIPTION: Allows viewing the repository's commit history as it was after a specific operation. This is useful for debugging or understanding the state of the repository at a particular point in time. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/tutorial.md#_snippet_19 LANGUAGE: shell CODE: ``` jj log --at-op=367400773f87 ``` ---------------------------------------- TITLE: Configure GitHub CLI with GIT_DIR DESCRIPTION: Explains how to configure the `GIT_DIR` environment variable to ensure GitHub CLI works correctly with Jujutsu repositories, especially non-colocated ones. It shows how to set `GIT_DIR` manually and how to automate this using direnv and a `.envrc` file. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/github.md#_snippet_8 LANGUAGE: shell CODE: ``` $ GIT_DIR=.jj/repo/store/git gh issue list ``` LANGUAGE: shell CODE: ``` export GIT_DIR=$PWD/.jj/repo/store/git ``` ---------------------------------------- TITLE: Configure Expected Exit Codes for Diff Tools DESCRIPTION: Suppresses warnings for specific non-success exit codes from external diff commands. This allows certain exit codes, which might indicate non-critical differences or specific tool behaviors, to be ignored without generating warnings. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_21 LANGUAGE: TOML CODE: ``` [merge-tools.delta] diff-expected-exit-codes = [0, 1] ``` ---------------------------------------- TITLE: Jujutsu: Push with Generated Bookmark DESCRIPTION: This snippet demonstrates how to create a new commit, add a feature, and then push it to GitHub using a Jujutsu-generated bookmark name. It pushes the parent of the working-copy commit. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/github.md#_snippet_0 LANGUAGE: shell CODE: ``` $ jj new main $ jj commit -m 'refactor(foo): restructure foo()' $ jj commit -m 'feat(bar): add support for bar' $ jj git push -c @- ``` ---------------------------------------- TITLE: Configure Immutable Commits Alias DESCRIPTION: Defines a custom set of immutable commits using revset aliases. This allows specifying which commits should not be rewritten, either by adding specific bookmarks or by excluding commits authored by other users. Ancestors of these commits are also considered immutable. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/config.md#_snippet_23 LANGUAGE: TOML CODE: ``` [revset-aliases] "immutable_heads()" = "builtin_immutable_heads() | release@origin" ``` LANGUAGE: TOML CODE: ``` # The `trunk().. &` bit is an optimization to scan for non-`mine()` commits # only among commits that are not in `trunk()`. [revset-aliases] "immutable_heads()" = "builtin_immutable_heads() | (trunk().. & ~mine())" ``` ---------------------------------------- TITLE: jj Alias for Cloud Sync (Dropbox) DESCRIPTION: This `jj` alias configures the `dropbox` command to interact with cloud storage using `rclone` and `execline`. It defines subcommands for pulling and pushing changes, including file synchronization, bookmark management, and repository cleanup. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/Dropbox,-Google-Drive,-Onedrive,-etc.--as-a-CVS------T^T.md#_snippet_0 LANGUAGE: jj CODE: ``` [aliases] dropbox = ["util", "exec", "--", "execlineb", "-s", "1", "-c", """ backtick -E root { jj root } define remote __REMOTE_NAME__ define remote_dir __REMOTE_DIR__ define local_dir __LOCAL_DIR__ # optionally make local backups of remote files #define local_backup ${local_dir}_backup backtick -E when { date +%Y-%m-%dT%H-%M-%S } execline-cd ${root} case $1 { pull { backtick -E current_change { jj log --no-graph -r @ -T "self.change_id()" } foreground { jj bookmark create ${current_change} -r@ } foreground { jj new dropbox } foreground { jj bookmark move dropbox --to=@ } foreground { jj desc -m "Pull from dropbox ${when}" } foreground { rclone sync ${remote}:${remote_dir} ./${local_dir} } # to make local backups of remote files comment the above line and uncomment the next one #foreground { rclone sync ${remote}:${remote_dir} ./${local_dir} --backup-dir=./${local_backup} --suffix=-${when} } foreground { forbacktickx -E map { cat file_map } multidefine -d : ${map} { a b } foreground { cp -p ${local_dir}/${a} ${b} } } foreground { jj new ${current_change} dropbox } foreground { jj bookmark delete ${current_change} } foreground { jj abandon -r "empty() & @-" --retain-bookmarks } foreground { jj simplify-parents } } push { foreground { forbacktickx -E map { cat file_map } multidefine -d : ${map} { a b } foreground { cp -p ${b} ${local_dir}/${a} } } foreground { rclone sync ./${local_dir} ${remote}:${remote_dir} } foreground { jj bookmark move dropbox --to=@ } foreground { jj new } foreground { jj abandon -r "empty() & @-" --retain-bookmarks } } } """ ] ``` ---------------------------------------- TITLE: Jujutsu: Track scratch files with gitignore patterns DESCRIPTION: This snippet demonstrates how to configure Jujutsu to ignore scratch files by adding patterns to `.gitignore` or global gitignore files. It also shows how to track specific files using `jj file track`. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/FAQ.md#_snippet_7 LANGUAGE: shell CODE: ``` jj config set --user git.private-commits "'''description(glob:'private:*')'''" ``` ---------------------------------------- TITLE: Generate contributor list locally DESCRIPTION: This command generates a list of contributors by querying the jj log for commits between the latest tags and the main branch, formatting the output for clarity and removing duplicates. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/releasing.md#_snippet_2 LANGUAGE: shell CODE: ``` jj log --no-graph -r 'heads(tags())..main' -T '"* " ++ author ++ "\n"' | sort -fu ``` ---------------------------------------- TITLE: Mahou Scripting Language Introduction DESCRIPTION: An introduction to Mahou, a user-level scripting language for the jj project, covering its design considerations and basic usage. This session provides an overview of a prototype scripting language. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/JJ-Con-2025.md#_snippet_0 LANGUAGE: English CODE: ``` A brief introduction to a user-level scripting language (prototype) for the project and its design considerations (aka jj script). ``` ---------------------------------------- TITLE: Pushing bookmarks with force-with-lease equivalent DESCRIPTION: This section explains how `jj git push` performs safety checks similar to `git push --force-with-lease` by verifying the remote bookmark's state against `jj`'s records to prevent conflicts. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/bookmarks.md#_snippet_11 LANGUAGE: shell CODE: ``` jj git push ``` LANGUAGE: shell CODE: ``` git push --force-with-lease ``` ---------------------------------------- TITLE: Large Scale Changes with JJ run DESCRIPTION: Demonstrates using 'jj run' to perform large-scale modifications across multiple repositories, both local and remote, by executing scripts or commands like 'sed'. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/design/run.md#_snippet_1 LANGUAGE: shell CODE: ``` jj run 'sed /some/test/' -r 'mine() & ~remote_bookmarks(exact:"origin")' jj run '$rewrite-tool' -r '$revset' ``` ---------------------------------------- TITLE: jj Git Push for Creating Branches DESCRIPTION: This command demonstrates how to use jj to push specific commits as separate branches, useful for workflows where individual commits need to be tracked or submitted. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/sapling-comparison.md#_snippet_0 LANGUAGE: jj CODE: ``` jj git push --change X --change Y ``` ---------------------------------------- TITLE: TreeEntry Methods DESCRIPTION: Outlines the methods for the TreeEntry type, which return details about a file system entry, such as its path, whether it's a conflict, its file type, and if it's executable. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_49 LANGUAGE: any CODE: ``` TreeEntry.path() TreeEntry.conflict() TreeEntry.file_type() TreeEntry.executable() ``` ---------------------------------------- TITLE: Jujutsu Template: Global Function - pad_start DESCRIPTION: The 'pad_start' function pads content by adding leading fill characters to reach a specified width. It accepts width, content, and an optional fill character, all as Templates. The content should not contain newline characters. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_5 LANGUAGE: Jujutsu Template CODE: ``` pad_start(width: Integer, content: Template, [fill_char: Template]) ``` ---------------------------------------- TITLE: Resolve Conflicts with jj DESCRIPTION: Details the process of resolving conflicts after a rebase operation. It shows how to create a new commit for the resolution, inspect the changes, and then squash the resolution into the conflicted commit using `jj new`, `jj st`, `cat`, `echo`, and `jj squash`. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/tutorial.md#_snippet_14 LANGUAGE: shell CODE: ``` $ jj new puqltutt # Replace the ID by what you have for B2 Working copy (@) now at: zxoosnnp c7068d1c (conflict) (empty) (no description set) Parent commit (@-) : puqltutt f7fb5943 (conflict) B2 Added 0 files, modified 0 files, removed 1 files Warning: There are unresolved conflicts at these paths: file1 2-sided conflict $ jj st The working copy has no changes. Working copy (@) : zxoosnnp c7068d1c (conflict) (empty) (no description set) Parent commit (@-): puqltutt f7fb5943 (conflict) B2 Warning: There are unresolved conflicts at these paths: file1 2-sided conflict Hint: To resolve the conflicts, start by creating a commit on top of the conflicted commit: jj new puqltutt Then use `jj resolve`, or edit the conflict markers in the file directly. Once the conflicts are resolved, you can inspect the result with `jj diff`. Then run `jj squash` to move the resolution into the conflicted commit. $ cat file1 <<<<<<< Conflict 1 of 1 %%%%%%% Changes from base to side #1 -b1 +a +++++++ Contents of side #2 b2 >>>>>>> Conflict 1 of 1 ends $ echo resolved > file1 $ jj st Working copy changes: M file1 Working copy (@) : zxoosnnp c2a31a06 (no description set) Parent commit (@-): puqltutt f7fb5943 (conflict) B2 Hint: Conflict in parent commit has been resolved in working copy $ jj squash Rebased 1 descendant commits Working copy (@) now at: ntxxqymr e3c279cc (empty) (no description set) Parent commit (@-) : puqltutt 2c7a658e B2 ``` ---------------------------------------- TITLE: Creating New Commits with jj new DESCRIPTION: This command is used to create a new commit on top of an existing one. It's part of the process for addressing feedback during code reviews, allowing changes to be made in a separate commit before squashing. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/contributing.md#_snippet_2 LANGUAGE: Shell CODE: ``` jj new ``` ---------------------------------------- TITLE: Rewrite Commits with JJ DESCRIPTION: Demonstrates how to rewrite commits using Jujutsu. This involves creating a new commit on top of a previous one, updating code, reviewing changes, squashing the changes into the parent commit, and pushing the updated bookmark to the remote. It utilizes `jj new`, `jj diff`, `jj squash`, and `jj git push`. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/github.md#_snippet_7 LANGUAGE: shell CODE: ``` $ jj new your-feature- # NOTE: the trailing hyphen is not a typo! $ jj diff $ jj squash $ jj git push --bookmark your-feature ``` ---------------------------------------- TITLE: Configure Gofmt for Go Formatting DESCRIPTION: This configuration sets up `gofmt`, the standard Go code formatter, to process Go files. It uses a simple command `["gofmt"]` and targets files matching the `**/*.go` glob pattern. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/Fix-tools.md#_snippet_2 LANGUAGE: toml CODE: ``` [fix.tools.gofmt] patterns = ["glob:'**/*.go'"] command = ["gofmt"] ``` ---------------------------------------- TITLE: View Commit History with jj log DESCRIPTION: Displays the commit history of the repository. The output shows commit hashes, author information, timestamps, and commit messages. It also indicates the current working copy and any conflicted states. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/tutorial.md#_snippet_15 LANGUAGE: shell CODE: ``` $ jj log @ ntxxqymr martinvonz@google.com 2023-02-12 19:34:09 e3c279cc │ (empty) (no description set) │ ○ qzvqqupx martinvonz@google.com 2023-02-12 19:34:09 b9da9d28 ├─╯ C ○ puqltutt martinvonz@google.com 2023-02-12 19:34:09 2c7a658e │ B2 │ ○ ovknlmro martinvonz@google.com 2023-02-12 15:07:24 7d7c6e6b ├─╯ B1 ○ nuvyytnq martinvonz@google.com 2023-02-12 15:07:05 5dda2f09 │ A │ ○ kntqzsqt martinvonz@google.com 2023-02-12 14:56:59 5d39e19d ├─╯ Say goodbye ◆ orrkosyo octocat@nowhere.com 2012-03-06 15:06:50 master 7fd1a60b │ (empty) Merge pull request #6 from Spaceghost/patch-1 ~ ``` ---------------------------------------- TITLE: Trailer Methods DESCRIPTION: Shows the methods for the Trailer type, which allow retrieval of the trailer's key and value. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_46 LANGUAGE: any CODE: ``` Trailer.key() Trailer.value() ``` ---------------------------------------- TITLE: Generate contributor list using GitHub API DESCRIPTION: This command uses the GitHub API to fetch commit data between two specified points (root and main) and processes it with jq to extract and format contributor information, excluding bots. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/releasing.md#_snippet_1 LANGUAGE: shell CODE: ``` root=$(jj log --no-graph -r 'heads(tags(glob:"v*.*.*") & ::trunk())' -T commit_id) filter=' map(.commits[] | select(.author.login | endswith("[bot]") | not)) | unique_by(.author.login) | map("* \(.commit.author.name) (@\(.author.login))") | .[] ' gh api "/repos/jj-vcs/jj/compare/$root...main" --paginate | jq -sr "$filter" | sort -f ``` ---------------------------------------- TITLE: View Commit Evolution Log in Jujutsu DESCRIPTION: The `jj evolog` command displays the history of changes for the current commit, including modifications to the working copy, message updates, squashes, and rebases. This provides insight into how a commit has evolved over time. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/tutorial.md#_snippet_8 LANGUAGE: shell CODE: ``` # Example usage (conceptual, as the command itself is shown in description): # jj evolog ``` ---------------------------------------- TITLE: Jujutsu: Address Review Comments by Rewriting Commit DESCRIPTION: This snippet demonstrates addressing review comments by creating a new commit, describing the changes without creating a new commit, updating the bookmark to the current commit, and then pushing. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/github.md#_snippet_6 LANGUAGE: shell CODE: ``` $ jj new your-feature $ jj diff $ jj describe -m 'address pr comments' $ jj bookmark move your-feature --to @ $ jj git push ``` ---------------------------------------- TITLE: Check Jujutsu Status DESCRIPTION: Displays the current status of the working copy in Jujutsu using the 'jj st' command. It shows the working copy commit and the parent commit, including their respective IDs and descriptions. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/tutorial.md#_snippet_1 LANGUAGE: shell CODE: ``` $ jj st The working copy has no changes. Working copy (@) : kntqzsqt d7439b06 (empty) (no description set) Parent commit (@-): orrkosyo 7fd1a60b master | (empty) Merge pull request #6 from Spaceghost/patch-1 ``` ---------------------------------------- TITLE: Jujutsu: Address Review Comments by Adding Commits DESCRIPTION: This workflow addresses review comments by creating a new commit on top of an existing bookmark ('your-feature'), updating the code, and then moving the bookmark to the new commit before pushing. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/github.md#_snippet_5 LANGUAGE: shell CODE: ``` $ jj new your-feature $ jj diff $ jj commit -m 'address pr comments' $ jj bookmark move your-feature --to @- $ jj git push ``` ---------------------------------------- TITLE: Help for jj pr command DESCRIPTION: Displays the help message and usage information for the `jj pr` Nushell command, outlining its subcommands for managing GitHub Pull Requests. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/Nushell.md#_snippet_0 LANGUAGE: bash CODE: ``` > jj pr --help Nushell command for opening Jujutsu PRs with GitHub Usage: > jj pr Subcommands: jj pr create (custom) - Create a PR for the current revision jj pr merge (custom) - Merge an open PR jj pr update base (custom) - Update a PRs base jj pr update desc (custom) - Update a PR description with revision details jj pr view (custom) - View details for a PR Flags: -h, --help: Display the help message for this command Input/output types: ╭───┬───────┬────────╮ │ # │ input │ output │ ├───┼───────┼────────┤ │ 0 │ any │ any │ ╰───┴───────┴────────╯ ``` ---------------------------------------- TITLE: List Bookmarks DESCRIPTION: Lists all available bookmarks in the Jujutsu repository. This command provides an overview of all named revision pointers. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/bookmarks.md#_snippet_1 LANGUAGE: jj CODE: ``` jj bookmark list ``` ---------------------------------------- TITLE: View Diff After Interactive Squash DESCRIPTION: Displays the difference between the parent commit and the current working copy after an interactive squash operation, showing the applied content changes. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/tutorial.md#_snippet_22 LANGUAGE: shell CODE: ``` $ jj diff -r @- --git diff --git a/file b/file index de980441c3..b1e67221af 100644 --- a/file +++ b/file @@ -1,3 +1,3 @@ -a -b -c +A +B +C ``` ---------------------------------------- TITLE: Manage Bookmarks DESCRIPTION: Provides subcommands for creating, moving, or deleting bookmarks. Use `jj bookmark ` to access these operations. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/bookmarks.md#_snippet_2 LANGUAGE: jj CODE: ``` jj bookmark ``` ---------------------------------------- TITLE: Split Commits with jj split DESCRIPTION: This snippet demonstrates how to use the `jj split` command to divide a commit into smaller, more manageable parts. This is useful when a commit needs to be refactored or when a single commit contains multiple logical changes. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/contributing.md#_snippet_0 LANGUAGE: Shell CODE: ``` jj split ``` ---------------------------------------- TITLE: View Jujutsu Commit Log with Diff DESCRIPTION: Displays the commit log with detailed diffs for each commit. This command is essential for understanding the changes introduced by each commit and the overall project history. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/FAQ.md#_snippet_16 LANGUAGE: console CODE: ``` $ jj log -p --git @ pvnrklkn jjfan@example.org 2025-02-28 21:39:29 468104c2 │ featureB │ diff --git a/file b/file │ index 2b455c4207..2a7e05a01a 100644 │ --- a/file │ +++ b/file │ @@ -1,1 +1,2 @@ │ Done with feature A │ +Working on feature B ○ lnvvtrzo jjfan@example.org 2025-02-28 21:00:51 b8004ab8 │ featureA │ diff --git a/file b/file │ new file mode 100644 │ index 0000000000..2b455c4207 │ --- /dev/null │ +++ b/file │ @@ -0,0 +1,1 @@ │ +Done with feature A ◆ zzzzzzzz root() 00000000 ``` ---------------------------------------- TITLE: Equivalent Sparse Pattern Rule Sets DESCRIPTION: Illustrates how multiple, distinct sets of sparse pattern rules can be functionally equivalent after canonicalization. This highlights the importance of the canonical form for consistent behavior. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/design/sparse-v2.md#_snippet_4 LANGUAGE: txt CODE: ``` # Set 1 include:dir:bar include:dir:foo # Set 2 include:dir:foo include:dir:bar # Set 3 include:dir:bar include:dir:bar/baz/qux include:dir:foo ``` ---------------------------------------- TITLE: Create a New Commit in Jujutsu DESCRIPTION: This command creates a new commit on top of the current working-copy commit, effectively finalizing the current set of changes. It then shows the status, indicating no further changes in the working copy and updating the working copy commit ID. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/tutorial.md#_snippet_5 LANGUAGE: shell CODE: ``` $ jj new ``` LANGUAGE: shell CODE: ``` Working copy (@) now at: mpqrykyp aef4df99 (empty) (no description set) Parent commit (@-) : kntqzsqt 5d39e19d Say goodbye ``` LANGUAGE: shell CODE: ``` $ jj st The working copy has no changes. Working copy (@) : mpqrykyp aef4df99 (empty) (no description set) Parent commit (@-): kntqzsqt 5d39e19d Say goodbye ``` ---------------------------------------- TITLE: Interactively Squash Changes with jj DESCRIPTION: Uses `jj squash -i` to interactively move parts of a commit's changes into its parent commit. This is useful for refining commit history by selectively applying changes. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/tutorial.md#_snippet_21 LANGUAGE: shell CODE: ``` $ jj squash -i Hint: Using default editor ':builtin'; run `jj config set --user ui.diff-editor :builtin` to disable this message. Rebased 1 descendant commits Working copy (@) now at: mrxqplyk 52a6c7fd ABCD Parent commit (@-) : kwtuwqnm 643061ac ABC ``` ---------------------------------------- TITLE: Micro Syntax Highlighting for JJ Commit Descriptions (YAML) DESCRIPTION: This YAML file defines custom syntax highlighting rules for Micro to recognize JJ commit descriptions. It includes rules for comments, keywords, and diff changes, with specific handling for the 'JJ: ignore-rest' command. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/Micro.md#_snippet_2 LANGUAGE: yaml CODE: ``` filetype: jj-commit detect: filename: "(\.(jjdescription)$)" rules: # Since jj v0.25.0, a `JJ: ignore-rest` line will comment out everything until the next describe block - comment.block: start: "^JJ: ignore-rest" # Impl note: Cannot use lookaheads in micro, so to highlight describe at all, i need to match this series of dashes after it # Assumption: The only lines ending in 7 dashes are the describe lines, and all describe lines will have dashes # If this assumption is broken, the highlighting will become incorrect end: " -------$" rules: - type.keyword: "describe [0-9a-f]{12}" - diff-added: " A (.+$" - diff-modified: " M (.+$" - diff-deleted: " D (.+$" # Otherwise, every line starting with JJ: is also considered a comment on its own - comment: start: "JJ:" end: "$" rules: - type.keyword: "describe [0-9a-f]{12}" - diff-added: "^ A (.+$" - diff-modified: "^ M (.+$" - diff-deleted: "^ D (.+$" ``` ---------------------------------------- TITLE: Load Repository at Specific Operation DESCRIPTION: Loads the repository at a specific operation using the --at-operation or --at-op option. This is useful for inspecting past states or simulating concurrent commands. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/operation-log.md#_snippet_4 LANGUAGE: bash CODE: ``` jj --at-op= ``` ---------------------------------------- TITLE: VS Code Editor Settings DESCRIPTION: Recommended Visual Studio Code settings for the project, focusing on file handling like inserting final newlines and trimming trailing whitespace. It specifically disables trimming trailing whitespace for Rust files. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/contributing.md#_snippet_9 LANGUAGE: js CODE: ``` { "files.insertFinalNewline": true, "files.trimTrailingWhitespace": true, "[rust]": { "files.trimTrailingWhitespace": false } } ``` ---------------------------------------- TITLE: Working Copy Mapping Text Syntax DESCRIPTION: This describes the compact text syntax for defining working copy mapping rules, used for editing in file form or adding rules via the CLI. It includes the format for specifying source and destination paths and an option for non-recursive mapping. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/design/sparse-v2.md#_snippet_6 LANGUAGE: txt CODE: ``` "" -> "" [nonrecursive] ``` ---------------------------------------- TITLE: Interactive Commit with jj split and jj squash DESCRIPTION: To interactively select changes for a commit, similar to `git add -p` or `hg commit -i`, use `jj split -i` or `jj commit -i`. For interactive amending, use `jj squash -i`. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/FAQ.md#_snippet_5 LANGUAGE: jj CODE: ``` jj split -i jj commit -i jj squash -i ``` ---------------------------------------- TITLE: Configure Beyond Compare for jj (Linux) DESCRIPTION: Sets up Beyond Compare as a merge tool for jj on Linux systems. It specifies the program to use ('bcompare') and arguments for both editing and merging operations, including read-only flags and conflict review. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/Beyond-Compare.md#_snippet_0 LANGUAGE: toml CODE: ``` [merge-tools.bc] program = "bcompare" # On MacOS, this should be "bcomp". edit-args = ["$left", "$right", "-ro1", "-expandall"] merge-args = ["$left", "$right", "$base", "$output", "-automerge", "-reviewconflicts"] [merge-tools.bc-3] # Alternative config similar to `meld-3`. program="bcompare" # On MacOS, this should be "bcomp". edit-args = ["$left", "$right", "-expandall", "-mergeoutput=$right", "-ro1", "-ro2"] # Optionally, can copy `merge-args` from the above example ``` ---------------------------------------- TITLE: Operation Methods DESCRIPTION: Provides methods to retrieve information about an operation, such as its current status, description, ID, tags, timestamps, user, and whether it's a snapshot or root operation. It also allows access to parent operations. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_35 LANGUAGE: jj CODE: ``` operation.current_operation() -> Boolean operation.description() -> String operation.id() -> OperationId operation.tags() -> String operation.time() -> TimestampRange operation.user() -> String operation.snapshot() -> Boolean operation.root() -> Boolean operation.parents() -> List ``` ---------------------------------------- TITLE: Add New Workspace with jj DESCRIPTION: Create a new working copy by adding a new workspace using the 'jj workspace add' command. This workspace will have a .jj/ directory linked to the main repository. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/working-copy.md#_snippet_8 LANGUAGE: bash CODE: ``` jj workspace add ``` ---------------------------------------- TITLE: WorkspaceRef Methods DESCRIPTION: Describes the methods for the WorkspaceRef type, allowing retrieval of the workspace name and its target commit. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_50 LANGUAGE: any CODE: ``` WorkspaceRef.name() WorkspaceRef.target() ``` ---------------------------------------- TITLE: Stupid jj Tricks DESCRIPTION: A presentation showcasing useful revset aliases, templates, aliases, and other configurations for efficiently accomplishing common tasks in JJ. This session aims to share practical tips and tricks. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/JJ-Con-2025.md#_snippet_3 LANGUAGE: English CODE: ``` A survey of interesting revset aliases, templates, aliases, and other configuration to accomplish common (or not so common) tasks ``` ---------------------------------------- TITLE: JJ-FZF Fuzzy Finder for Jujutsu DESCRIPTION: JJ-FZF is a fuzzy finder wrapper for Jujutsu, centered around the `jj log` graph view. It offers previews of diffs, evolution-log browsing, op log interaction, and numerous key bindings for common Jujutsu operations like rebase and undo, aiding in managing divergent commits. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/community_tools.md#_snippet_2 LANGUAGE: bash CODE: ``` # jj-fzf is a command-line tool. Usage typically involves invoking it directly. # Example: jj-fzf log # This would launch the fzf interface for the jj log. ``` ---------------------------------------- TITLE: Tracking Remote Bookmarks DESCRIPTION: The `jj bookmark track` command is used to make a remote bookmark 'tracked'. This creates a local bookmark that mirrors the state of the remote bookmark. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/glossary.md#_snippet_4 LANGUAGE: Jujutsu CLI CODE: ``` jj bookmark track ``` ---------------------------------------- TITLE: Configure Multiple Git Remotes in JJ DESCRIPTION: Details how to configure Jujutsu to use multiple Git remotes, such as 'upstream' for contributions and 'origin' for a personal fork. It shows how to add remotes and configure default fetch and push remotes in the `config.toml` file. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/github.md#_snippet_10 LANGUAGE: shell CODE: ``` $ jj git clone --remote upstream https://github.com/upstream-org/repo $ cd repo $ jj git remote add origin git@github.com:your-org/your-repo-fork ``` ---------------------------------------- TITLE: RepoPath Display and Parent DESCRIPTION: Defines methods for RepoPath to format the path for display using platform-native separators and to retrieve the parent directory path as an optional RepoPath. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_37 LANGUAGE: jj CODE: ``` repo_path.display() -> String repo_path.parent() -> Option ``` ---------------------------------------- TITLE: Set Neovim as Editor DESCRIPTION: This TOML configuration sets Neovim as the default editor for `jj` commands like `describe`. It's a simple configuration that points `jj` to the `nvim` executable. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/Vim,-Neovim.md#_snippet_2 LANGUAGE: toml CODE: ``` ui.editor = "nvim" ``` ---------------------------------------- TITLE: Load Repo at Specific Operation in Jujutsu DESCRIPTION: Demonstrates how to load the Jujutsu repository at a specific operation ID using the `--at-operation` flag. This is useful for inspecting past states or simulating divergent operations. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/technical/concurrency.md#_snippet_0 LANGUAGE: Shell CODE: ``` jj --at-operation= ``` ---------------------------------------- TITLE: CommitEvolutionEntry Methods DESCRIPTION: Provides methods to access the new commit and the operation associated with a commit evolution entry. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_24 LANGUAGE: jj-vcs CODE: ``` `.commit() -> Commit` .operation() -> Operation ``` ---------------------------------------- TITLE: Alternative jj Prompt with Emojis (TOML) DESCRIPTION: Sets up an alternative Starship prompt using emojis for jj status (conflict, divergent, hidden, immutable) and displays the shortest change ID and description. It also includes logic to disable default Git modules when a jj repository is detected. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/Starship.md#_snippet_1 LANGUAGE: toml CODE: ``` # custom module for jj status [custom.jj] description = "The current jj status" when = "jj --ignore-working-copy root" symbol = "🥋 " command = ''' jj log --revisions @ --no-graph --ignore-working-copy --color always --limit 1 --template ' separate(" ", change_id.shortest(4), bookmarks, "|", concat( if(conflict, "💥"), if(divergent, "🚧"), if(hidden, "👻"), if(immutable, "🔒"), ), raw_escape_sequence("\x1b[1;32m") ++ if(empty, "(empty)"), raw_escape_sequence("\x1b[1;32m") ++ coalesce( truncate_end(29, description.first_line(), "…"), "(no description set)", ) ++ raw_escape_sequence("\x1b[0m"), ) ' ''' # optionally disable git modules when JJ is found. # note that you'll need to add ${custom.git_branch}, ${custom.git_commit} etc # into format: https://starship.rs/config/#default-prompt-format [git_status] disabled = true [custom.git_status] when = "! jj --ignore-working-copy root" command = "starship module git_status" style = "" # This disables the default "(bold green)" style description = "Only show git_status if we're not in a jj repo" [git_commit] disabled = true [custom.git_commit] when = "! jj --ignore-working-copy root" command = "starship module git_commit" style = "" description = "Only show git_commit if we're not in a jj repo" [git_metrics] disabled = true [custom.git_metrics] when = "! jj --ignore-working-copy root" command = "starship module git_metrics" description = "Only show git_metrics if we're not in a jj repo" style = "" [git_branch] disabled = true [custom.git_branch] when = "! jj --ignore-working-copy root" command = "starship module git_branch" description = "Only show git_branch if we're not in a jj repo" style = "" ``` ---------------------------------------- TITLE: Create New Revision with Bookmark DESCRIPTION: Creates a new revision on top of a specified bookmark. This command requires the bookmark name as an argument. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/bookmarks.md#_snippet_0 LANGUAGE: jj CODE: ``` jj new main ``` ---------------------------------------- TITLE: Zed Editor Settings for Rust and Markdown DESCRIPTION: Configuration for the Zed editor, specifying settings for ensuring final newlines and removing trailing whitespace on save. It customizes behavior for Markdown and Rust files, including enabling Rust formatting on save with nightly toolchain. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/contributing.md#_snippet_10 LANGUAGE: js CODE: ``` // .zed/settings.json { "ensure_final_newline_on_save": true, "remove_trailing_whitespace_on_save": true, "languages": { // We don't use a formatter for Markdown files, so format_on_save would just // mess with others' docs "Markdown": { "format_on_save": "off" } "Rust": { "format_on_save": "on", // Avoid removing trailing spaces within multi-line string literals "remove_trailing_whitespace_on_save": false } }, "lsp": { "rust-analyzer": { "initialization_options": { // If you are working on docs and don't need `cargo check`, uncomment // this option: // // "checkOnSave": false, // Use nightly `rustfmt`, equivalent to `cargo +nightly fmt` "rustfmt": { "extraArgs": ["+nightly"] } } } } } ``` ---------------------------------------- TITLE: jj string matching patterns DESCRIPTION: Explains the various string matching patterns supported by jj-vcs functions, including substring, exact, glob, and regex matching, with case-insensitive options. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_68 LANGUAGE: jj CODE: ``` "string" ``` LANGUAGE: jj CODE: ``` substring:"string" ``` LANGUAGE: jj CODE: ``` exact:"string" ``` LANGUAGE: jj CODE: ``` glob:"pattern" ``` LANGUAGE: jj CODE: ``` regex:"pattern" ``` LANGUAGE: jj CODE: ``` glob-i:"fix*jpeg*" ``` ---------------------------------------- TITLE: Configure Biome for JavaScript/TypeScript/JSON Formatting DESCRIPTION: This configuration sets up Biome, a JavaScript formatter and linter, to run against specified JavaScript, TypeScript, and JSON files. It uses the `biome check --write` command and accepts source code via standard input, with the file path provided via the `$path` variable. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/Fix-tools.md#_snippet_0 LANGUAGE: toml CODE: ``` [fix.tools.biome] command = ["biome", "check", "--stdin-file-path=$path", "--write"] patterns = [ "glob:'**/*.js'", "glob:'**/*.jsx'", "glob:'**/*.ts'", "glob:'**/*.tsx'", "glob:'**/*.json'", ] ``` ---------------------------------------- TITLE: Fetch from Git Remote and Update Bookmarks DESCRIPTION: Fetches changes from a Git remote and automatically imports them, creating or updating corresponding Jujutsu bookmarks. This is particularly relevant for colocated repositories. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/bookmarks.md#_snippet_4 LANGUAGE: jj CODE: ``` jj git fetch --remote origin ``` ---------------------------------------- TITLE: List Operations DESCRIPTION: Provides specific methods for lists of trailers, such as checking if a specific key exists within the commit description's trailers. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_33 LANGUAGE: Rust CODE: ``` list_of_trailer.contains_key(key) ``` ---------------------------------------- TITLE: Add jj prompt to fish_vcs_prompt DESCRIPTION: This snippet demonstrates how to modify the `fish_vcs_prompt` function in Fish shell to include the `fish_jj_prompt`. It shows the insertion point and the necessary line to call the jj prompt before other version control prompts. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/Fish-shell.md#_snippet_0 LANGUAGE: fish CODE: ``` function fish_vcs_prompt --description 'Print all vcs prompts' # If a prompt succeeded, we assume that it's printed the correct info. # This is so we don't try svn if git already worked. fish_jj_prompt $argv or fish_git_prompt $argv or fish_hg_prompt $argv or fish_fossil_prompt $argv # The svn prompt is disabled by default because it's quite slow on common svn repositories. # To enable it uncomment it. # You can also only use it in specific directories by checking $PWD. # or fish_svn_prompt end ``` ---------------------------------------- TITLE: View Evolution Log with jj evolog DESCRIPTION: Shows the history of working copy snapshots, including obsolete (hidden) commits. This helps in finding the exact state before unintended changes were made. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/FAQ.md#_snippet_10 LANGUAGE: console CODE: ``` $ jj evolog @ lnvvtrzo jjfan@example.com 2025-02-28 21:01:10 31a347e0 │ featureA │ -- operation 3cb7392c092c snapshot working copy ○ lnvvtrzo hidden jjfan@example.com 2025-02-28 21:00:51 b8004ab8 │ featureA │ -- operation 1280bfaec893 snapshot working copy ○ lnvvtrzo hidden jjfan@example.com 2025-02-28 20:50:05 e4d831d (no description set) -- operation 0418a5aa94b5 snapshot working copy ``` ---------------------------------------- TITLE: Jujutsu: Amending Commits with Specific Files DESCRIPTION: This illustrates how to replicate Git's `git add -p; git commit --amend` workflow in Jujutsu. Jujutsu provides `jj squash -i` to select changes for the parent commit or `jj squash ` to move specific files. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/git-comparison.md#_snippet_1 LANGUAGE: Jujutsu CODE: ``` jj squash -i ``` LANGUAGE: Jujutsu CODE: ``` jj squash ``` ---------------------------------------- TITLE: Propagate changes to copied file, then rebase back DESCRIPTION: Demonstrates rebasing a commit onto another, showing how changes to copied files are handled when propagation is not automatic. It illustrates the state of the tree when conflicts are left unresolved and how they are resolved in a subsequent rebase. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/design/copy-tracking.md#_snippet_10 LANGUAGE: console CODE: ``` M foo="M" | | L copy foo->bar |/ K add foo="K" ``` ---------------------------------------- TITLE: Jujutsu UI Terminal User Interface DESCRIPTION: jjui is a terminal user interface specifically built for working with the Jujutsu version control system. It offers a command-line based interface for managing Jujutsu projects. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/community_tools.md#_snippet_8 LANGUAGE: go CODE: ``` // jjui is a Go-based TUI application. // Usage typically involves running the compiled binary. // Example: jjui // This launches the terminal user interface for Jujutsu. ``` ---------------------------------------- TITLE: Hunk.nvim Neovim Diff-Editor for Jujutsu DESCRIPTION: Hunk.nvim is a Neovim-based diff-editor that serves as an alternative to Jujutsu's built-in diff-editor. It enhances the diffing experience within Neovim. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/community_tools.md#_snippet_1 LANGUAGE: lua CODE: ``` -- Hunk.nvim is a Neovim plugin, typically configured via a plugin manager. -- Example configuration snippet (may vary based on plugin manager): -- require('hunk').setup() ``` ---------------------------------------- TITLE: Resolving bookmark conflicts with jj DESCRIPTION: This section details how to resolve conflicts in local and remote bookmarks using various `jj` commands. It covers checking status, listing conflicts, and using commands like `jj bookmark move`, `jj new`, and `jj rebase`. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/bookmarks.md#_snippet_12 LANGUAGE: shell CODE: ``` jj status ``` LANGUAGE: shell CODE: ``` jj bookmark list ``` LANGUAGE: shell CODE: ``` jj log ``` LANGUAGE: shell CODE: ``` jj new main?? ``` LANGUAGE: shell CODE: ``` jj new main ``` LANGUAGE: shell CODE: ``` jj bookmark move ``` LANGUAGE: shell CODE: ``` jj new 'all:main' ``` LANGUAGE: shell CODE: ``` jj rebase ``` LANGUAGE: shell CODE: ``` jj git fetch ``` ---------------------------------------- TITLE: GG GUI for Jujutsu DESCRIPTION: GG is a cross-platform GUI application for Jujutsu, simplifying graph manipulation workflows. Its README.md provides detailed usage instructions. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/community_tools.md#_snippet_0 ---------------------------------------- TITLE: Configure Ruff for Python Linting and Formatting DESCRIPTION: This configuration integrates Ruff, a fast Python linter and formatter, into the workflow. It uses the `ruff - --stdin-filename=$path` command to process Python files specified by the `**/*.py` glob pattern. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/Fix-tools.md#_snippet_5 LANGUAGE: toml CODE: ``` [fix.tools.ruff] command = ["ruff", "-", "--stdin-filename=$path"] patterns = ["glob:'**/*.py'"] ``` ---------------------------------------- TITLE: Pushing Changes with jj git push DESCRIPTION: This command is used to push changes to a remote repository. It's mentioned in the context of code reviews, where changes are made to existing commits and then pushed. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/contributing.md#_snippet_1 LANGUAGE: Shell CODE: ``` jj git push ``` ---------------------------------------- TITLE: JJ Design Session: Handling Large and Deep Directories DESCRIPTION: Addresses challenges with very large (~100k entries) and deep (~15 levels) directories in JJ. Proposes using prolly trees on a flat file list as a potential solution, acknowledging it's not Git-compatible. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/JJ-Con-2025.md#_snippet_7 LANGUAGE: English CODE: ``` **Handling very large directories and deep directories**: We have two kinds of problematic directories at Google. Some are very large (~100k entries). This makes them expensive to pass around and work with. Some directories are very deep (~15 levels?). This results in many round-trips to the server to find the leaves. It seems like we should be able to solve both problems by using something like prolly trees on a flat list of all the files in the repo. We have discussed this a bit internally and it seems promising, but it's going to be a lot of work, and not Git-compatible. This session would be about sharing the idea with others and hearing your feedback. ``` ---------------------------------------- TITLE: Viewing All Visible Commits in jj log DESCRIPTION: Explains how to use the `..` operator with `jj log` to display all visible commits in the repository, similar to `git log`. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/FAQ.md#_snippet_2 LANGUAGE: sh CODE: ``` jj log -r .. ``` ---------------------------------------- TITLE: View Working Copy Evolution with jj evolog DESCRIPTION: This command displays the history of commits that were previously the working-copy commit. It helps visualize the evolution of changes in the working copy over time. Obsolete changes are marked as hidden but remain accessible. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/FAQ.md#_snippet_3 LANGUAGE: jj CODE: ``` jj evolog jj evolog -r jj evolog -p ``` ---------------------------------------- TITLE: Switch Jujutsu to Git's Pager on Windows DESCRIPTION: This configuration switches Jujutsu's default integrated pager to Git's 'less.exe' pager on Windows, allowing for custom pagination behavior. It sets the `ui.pager` to Git's less executable and `ui.paginate` to 'auto'. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/windows.md#_snippet_1 LANGUAGE: PowerShell CODE: ``` PS> jj config set --user ui.pager '["C:\\Program Files\\Git\\usr\\bin\\less.exe", "-FRX"]' PS> jj config set --user ui.paginate auto ``` ---------------------------------------- TITLE: Show initial commits (root commits) DESCRIPTION: This shell command in jj-vcs displays the initial commits of the repository, often referred to as 'root commits' in Git. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_76 LANGUAGE: shell CODE: ``` jj log -r 'root()+' ``` ---------------------------------------- TITLE: Squashing Commits with jj squash DESCRIPTION: This command is used to combine the current commit with the previous one. It's employed during code reviews to integrate changes made in new commits back into the original commit. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/contributing.md#_snippet_3 LANGUAGE: Shell CODE: ``` jj squash ``` ---------------------------------------- TITLE: Jujutsu: Update Repository with Fetch and Rebase DESCRIPTION: This snippet illustrates how to update a Jujutsu repository by fetching changes from Git and then rebasing. This is the current method for updating as Jujutsu lacks a direct 'pull' equivalent. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/github.md#_snippet_2 LANGUAGE: shell CODE: ``` $ jj git fetch $ jj rebase -d $main_bookmark ``` ---------------------------------------- TITLE: Visual Jujutsu fzf Wrapper for Jujutsu DESCRIPTION: VJJ is a fuzzy finder (fzf) wrapper for Jujutsu, designed for interactive use within the terminal. It enhances the command-line experience by integrating fuzzy searching capabilities. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/community_tools.md#_snippet_6 LANGUAGE: bash CODE: ``` # VJJ is a command-line tool that wraps fzf and Jujutsu. # Example usage might involve piping output from jj commands to vjj. # Example: jj log | vjj ``` ---------------------------------------- TITLE: Versioning Metadata in JJ DESCRIPTION: Discusses the increasing need to version control metadata associated with files, not just their content. Explores use cases and challenges in handling metadata versioning. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/JJ-Con-2025.md#_snippet_2 LANGUAGE: English CODE: ``` We're seeing more and more use cases that require version-controlling not just file contents, but also a lot of metadata associated with them. ``` ---------------------------------------- TITLE: Compare Revisions with Jujutsu Diff DESCRIPTION: Compares two revisions to show the differences between them. This is useful for verifying that certain commits have the expected content or that changes have been applied correctly. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/FAQ.md#_snippet_17 LANGUAGE: console CODE: ``` $ jj diff --from b80 --to @ $ jj diff --from 31a --to @ ``` ---------------------------------------- TITLE: Jujutsu Backend Configuration DESCRIPTION: The specific commit backend used by Jujutsu when loading a repository is determined by the content of the '.jj/repo/store/type' file. Similar configuration files exist for other backends, such as '.jj/repo/index/type', '.jj/repo/op_store/type', and '.jj/repo/op_heads/type'. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/technical/architecture.md#_snippet_3 LANGUAGE: Rust CODE: ``` The commit backend to use when loading a repo is specified in the `.jj/repo/store/type` file. There are similar files for the other backends (`.jj/repo/index/type`, `.jj/repo/op_store/type`, `.jj/repo/op_heads/type`). ``` ---------------------------------------- TITLE: Configure Neovim as Diff Editor with Git Tooling DESCRIPTION: This TOML configuration sets up Neovim as a merge tool for `jj` operations like `jj split -i`. It uses a shell script to create a temporary git repository, stage changes, and invoke Neovim for editing. This allows leveraging existing git tooling within Neovim for hunk management. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/Vim,-Neovim.md#_snippet_4 LANGUAGE: toml CODE: ``` [merge-tools.neovim] program = "sh" edit-args = [ "-c", """ set -eu rm -f \"$right/JJ-INSTRUCTIONS\" git -C \"$left\" init -q git -C \"$left\" add -A git -C \"$left\" commit -q -m baseline --allow-empty # create parent commit mv \"$left/.git\" \"$right\" git -C \"$right\" add --intent-to-add -A # create current working copy (cd \"$right\"; nvim) git -C \"$right\" diff-index --quiet --cached HEAD && { echo \"No changes done, aborting split.\"; exit 1; } git -C \"$right\" commit -q -m split # create commit on top of parent including changes git -C \"$right\" restore . # undo changes in modified files git -C \"$right\" reset . # undo --intent-to-add git -C \"$right\" clean -q -df # remove untracked files """ ] ``` ---------------------------------------- TITLE: jj Function: bookmarks() DESCRIPTION: The bookmarks() function returns all local bookmark targets. An optional pattern can filter bookmarks by name. Conflicted bookmarks include all their possible targets. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_29 LANGUAGE: jj CODE: ``` bookmarks() bookmarks(pattern) ``` ---------------------------------------- TITLE: FZF-JJ Script for Revset Selection DESCRIPTION: FZF-JJ is a simple script designed to help users discover and select useful revsets within the jj version control system. This script differs from JJ-FZF by focusing specifically on revset discovery. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/fzf.md#_snippet_1 LANGUAGE: bash CODE: ``` ## FZF-JJ (revset selection) _Having trouble remembering useful revsets?_ [fzf-jff](https://gist.github.com/fzakaria/25a3e5cd0005d96e9a69a3496ecbee7f) is a simple script to help discover a collection of useful revsets. This is difference than JJ-FZF which is a more comprehensive TUI. > Note: Once `jj util exec` is released this can be powered by `jj` directly via an alias like `jj rlog` ``` ---------------------------------------- TITLE: ShortestIdPrefix Manipulation DESCRIPTION: Provides methods to access the prefix and rest of a ShortestIdPrefix, and to convert it to its uppercase or lowercase representation. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_38 LANGUAGE: jj CODE: ``` shortest_id_prefix.prefix() -> String shortest_id_prefix.rest() -> String shortest_id_prefix.upper() -> ShortestIdPrefix shortest_id_prefix.lower() -> ShortestIdPrefix ``` ---------------------------------------- TITLE: Label Function Usage DESCRIPTION: Demonstrates the use of the 'label()' function to insert arbitrary labels within template fragments for output customization. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_52 LANGUAGE: any CODE: ``` label(label, content) ``` ---------------------------------------- TITLE: jj log --color=debug DESCRIPTION: Demonstrates how to use the '--color=debug' option with the 'jj log' command to inspect output fragment labeling. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_43 LANGUAGE: sh CODE: ``` jj log --color=debug ``` ---------------------------------------- TITLE: Configure JJ Project Root Detection in Emacs DESCRIPTION: This snippet configures Emacs' `project.el` to recognize JJ repositories by adding `.jj` to the list of version control root markers. This is necessary because `project.el`'s default heuristics might not detect JJ repositories if they are not colocated with a `.git` directory. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/Emacs.md#_snippet_0 LANGUAGE: elisp CODE: ``` (use-package project :config (add-to-list 'project-vc-extra-root-markers ".jj")) ``` ---------------------------------------- TITLE: Describe Operation DESCRIPTION: Allows describing an operation, potentially simulating the state of the repository at a past operation. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/operation-log.md#_snippet_8 LANGUAGE: bash CODE: ``` jj --at-op= describe ``` ---------------------------------------- TITLE: Create New Commit from Intermediate Work with jj new DESCRIPTION: When you have unfinished work and want to save an intermediate state without committing, use `jj new`. This creates a new working-copy commit on top of the previous one, allowing you to return to earlier states. Use `jj squash` to amend the previous commit later. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/FAQ.md#_snippet_4 LANGUAGE: jj CODE: ``` jj new jj squash ``` ---------------------------------------- TITLE: Selvejj JetBrains Plugin for Jujutsu DESCRIPTION: Selvejj is a JetBrains IDE plugin that integrates Jujutsu as a first-class Version Control System (VCS) within the IDE. It allows developers to manage Jujutsu projects directly from their JetBrains environment. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/community_tools.md#_snippet_9 LANGUAGE: java CODE: ``` // Selvejj is a JetBrains IDE plugin. // Installation is typically done through the JetBrains Plugin Marketplace. // The plugin provides UI elements and actions for Jujutsu integration within the IDE. ``` ---------------------------------------- TITLE: List Available Fonts in ImageMagick DESCRIPTION: Lists all fonts that ImageMagick is aware of on the system. This command is useful for troubleshooting font-related issues when generating image outputs. SOURCE: https://github.com/jj-vcs/jj/blob/main/demos/README.md#_snippet_1 LANGUAGE: shell CODE: ``` convert -list Fonts ``` ---------------------------------------- TITLE: TreeDiffEntry Methods DESCRIPTION: Explains the methods for the TreeDiffEntry type, which provide information about changed files, including their path, status, source, and target. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_48 LANGUAGE: any CODE: ``` TreeDiffEntry.path() TreeDiffEntry.status() TreeDiffEntry.source() TreeDiffEntry.target() ``` ---------------------------------------- TITLE: Configure Neovim Editor with Flatten Plugin DESCRIPTION: This TOML configuration specifies Neovim as the editor for `jj` commands, specifically integrating with the `flatten.nvim` plugin. It sets a variable `g:flatten_wait` to 1, ensuring that `jj` waits for the Neovim instance to close before proceeding, which is crucial for proper file handling. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/Vim,-Neovim.md#_snippet_3 LANGUAGE: toml CODE: ``` ui.editor = ["nvim", "--cmd", "let g:flatten_wait=1"] ``` ---------------------------------------- TITLE: Restore Repository to Old Version DESCRIPTION: Restores the entire repository to the state it was in at a specified earlier operation. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/operation-log.md#_snippet_3 LANGUAGE: bash CODE: ``` jj op restore ``` ---------------------------------------- TITLE: Configure Jujutsu for Gerrit Integration DESCRIPTION: This TOML configuration snippet enables automatic addition of Change-Id trailers to commit messages for seamless Gerrit integration. It checks for the presence of 'Change-Id' before formatting to prevent duplicates. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/FAQ.md#_snippet_20 LANGUAGE: toml CODE: ``` [templates] commit_trailers = ''' if( !trailers.contains_key("Change-Id"), format_gerrit_change_id_trailer(self) ) ''' ``` ---------------------------------------- TITLE: Jujutsu Template: Global Function - fill DESCRIPTION: The 'fill' function fills lines to a specified width. It takes an Integer for the width and a Template for the content to be filled. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_3 LANGUAGE: Jujutsu Template CODE: ``` fill(width: Integer, content: Template) -> Template ``` ---------------------------------------- TITLE: Jujutsu Template: Global Function - surround DESCRIPTION: The 'surround' function wraps non-empty content with a prefix and suffix, such as parentheses. It requires prefix, suffix, and content Templates. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_19 LANGUAGE: Jujutsu Template CODE: ``` surround(prefix: Template, suffix: Template, content: Template) -> Template ``` ---------------------------------------- TITLE: Configure CSharpier for C# Formatting DESCRIPTION: This configuration integrates CSharpier, a C# code formatter, to automatically format C# files. It uses the `dotnet csharpier --write-stdout` command and targets files matching the `**/*.cs` glob pattern. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/Fix-tools.md#_snippet_1 LANGUAGE: toml CODE: ``` [fix.tools.csharpier] command = ["dotnet", "csharpier", "--write-stdout"] patterns = ["root-glob:'**/*.cs'"] ``` ---------------------------------------- TITLE: Configure JJ Logging DESCRIPTION: JJ's internal logs can be controlled using the JJ_LOG environment variable, similar to RUST_LOG. It accepts directives for log levels and targets. The --debug flag provides a convenient way to enable debug logs for specific components. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/contributing.md#_snippet_23 LANGUAGE: shell CODE: ``` JJ_LOG=debug jj ``` LANGUAGE: shell CODE: ``` jj --debug ``` ---------------------------------------- TITLE: Ignore .jj Directory in Vite Configuration DESCRIPTION: This JavaScript configuration snippet demonstrates how to ignore the '.jj' directory in Vite's file watching process. This prevents performance issues and potential conflicts when using Jujutsu within a Vite/Vitest project. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/FAQ.md#_snippet_21 LANGUAGE: javascript CODE: ``` export default defineConfig({ // ... other config like plugins, test setup, etc. server: { watch: { ignored: [ "**/.jj/**", ] } }, }) ``` ---------------------------------------- TITLE: JJ Configuration for Micro Editor (Properties) DESCRIPTION: This snippet shows the configuration in the JJ properties file to set Micro as the default editor. It can be added directly or under the 'ui' heading. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/Micro.md#_snippet_1 LANGUAGE: properties CODE: ``` ui.editor = "micro" # Alternatively, you can add it under the ui heading as follows # [ui] # editor = "micro" ``` ---------------------------------------- TITLE: Restore Files from Any Commit with jj restore DESCRIPTION: Restores files from any specified commit into the current working copy using the `jj restore` command, similar to `git restore`. SOURCE: https://github.com/jj-vcs/jj/blob/main/README.md#_snippet_6 LANGUAGE: Shell CODE: ``` jj restore --from --to ``` ---------------------------------------- TITLE: Show all ancestors of working copy DESCRIPTION: This shell command lists all ancestor commits of the current working directory in jj-vcs, analogous to a plain 'git log'. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_73 LANGUAGE: shell CODE: ``` jj log -r ::@ ``` ---------------------------------------- TITLE: Jujutsu Template: Global Function - indent DESCRIPTION: The 'indent' function indents non-empty lines with a given prefix. It requires a Template for the prefix and a Template for the content. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_4 LANGUAGE: Jujutsu Template CODE: ``` indent(prefix: Template, content: Template) -> Template ``` ---------------------------------------- TITLE: jj log with filename translation DESCRIPTION: Discusses how the 'jj log ' command might be translated into a revset query. The goal is to match specific (path, copy ID) pairs rather than just paths, leveraging the copy graph information. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/design/copy-tracking.md#_snippet_17 ---------------------------------------- TITLE: Squash Working Copy Changes into Parent Commit DESCRIPTION: The `jj squash` command moves changes from a given commit into its parent commit. When run on the working-copy commit, it functions similarly to `git commit --amend`, allowing you to combine recent changes into the previous commit. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/tutorial.md#_snippet_6 LANGUAGE: shell CODE: ``` # Example usage (conceptual, as the command itself is shown in description): # jj squash ``` ---------------------------------------- TITLE: View Operation Log DESCRIPTION: Displays the operation log, showing a history of repository modifications. Each entry includes a snapshot (view) of the repository's state at the end of the operation. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/operation-log.md#_snippet_0 LANGUAGE: bash CODE: ``` jj op log ``` ---------------------------------------- TITLE: View Evolution Log with Git Diffs using jj evolog --patch --git DESCRIPTION: Displays the evolution log along with git-formatted diffs for each commit. This allows for detailed comparison of changes between different versions of a commit, helping to pinpoint the exact commit to revert to. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/FAQ.md#_snippet_11 LANGUAGE: console CODE: ``` $ jj evolog --patch --git @ lnvvtrzo jjfan@example.com 2025-02-28 21:01:10 31a347e0 │ featureA │ -- operation 3cb7392c092c snapshot working copy │ diff --git a/file b/file │ index 2b455c4207..2a7e05a01a 100644 │ --- a/file │ +++ b/file │ @@ -1,1 +1,2 @@ │ Done with feature A │ +Working on feature B ○ lnvvtrzo hidden jjfan@example.com 2025-02-28 21:00:51 b8004ab8 │ featureA │ -- operation 1280bfaec893 snapshot working copy │ diff --git a/file b/file │ index cb61245109..2b455c4207 │ --- a/file │ +++ b/file │ @@ -1,1 +1,1 @@ │ -Working on feature A │ +Done with feature A ○ lnvvtrzo hidden jjfan@example.com 2025-02-28 20:50:05 e4d831d (no description set) -- operation 0418a5aa94b5 snapshot working copy diff --git a/file b/file index 0000000000..cb61245109 --- /dev/null +++ b/file @@ 0,0 +1,1 @@ +Working on feature A ``` ---------------------------------------- TITLE: Abbreviated jj bookmark commands DESCRIPTION: This section demonstrates the use of one-letter shortcuts for `jj bookmark` commands, such as `jj b` for `jj bookmark` and abbreviated subcommands. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/bookmarks.md#_snippet_14 LANGUAGE: shell CODE: ``` jj b c BOOKMARK-NAME -r@ ``` LANGUAGE: shell CODE: ``` jj bookmark create BOOKMARK-NAME -r@ ``` ---------------------------------------- TITLE: Jujutsu Template: Global Function - label DESCRIPTION: The 'label' function applies a label to content, evaluating the label as a space-separated string. It takes a Stringify label and a Template content. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_11 LANGUAGE: Jujutsu Template CODE: ``` label(label: Stringify, content: Template) -> Template ``` ---------------------------------------- TITLE: Edit and Amend Commits in Jujutsu DESCRIPTION: The `jj edit ` command allows you to resume editing a specific commit in the working copy. Subsequent changes will amend that commit. This is useful for making final adjustments before finalizing a change, often followed by `jj new` and `jj squash`. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/tutorial.md#_snippet_7 LANGUAGE: shell CODE: ``` # Example usage (conceptual, as the command itself is shown in description): # jj edit ``` ---------------------------------------- TITLE: Test case with conflict resolution and rebasing DESCRIPTION: Presents a test case involving conflict resolution and rebasing. It outlines a sequence of operations including adding files, renaming, and rebasing, and specifies the expected state of an auto-merged commit. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/design/copy-tracking.md#_snippet_16 LANGUAGE: console CODE: ``` $ jj log E baz="baz" (resolves conflict) | D | D C | rename bar->baz | | | B rename foo->baz |/ A add foo="foo" and bar="bar" $ jj rebase -r E -d C $ jj new D E -m F ``` ---------------------------------------- TITLE: Jujutsu List Files Excluding Rust Sources DESCRIPTION: Shows how to list files within the 'src' directory while excluding all Rust source files (files ending in '.rs'). SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/filesets.md#_snippet_1 LANGUAGE: shell CODE: ``` jj file list 'src ~ glob:"**/*.rs"' ``` ---------------------------------------- TITLE: Move Bookmarks in Jujutsu DESCRIPTION: Moves a bookmark from one revision to another. This is typically done after reorganizing commits or when updating references to specific points in history. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/FAQ.md#_snippet_14 LANGUAGE: console CODE: ``` $ jj bookmark move --from 31a347e0 --to b8004ea8 ``` ---------------------------------------- TITLE: Log Full Commit and Change IDs in Machine-Readable Format DESCRIPTION: Displays a machine-readable list of full commit and change IDs for commits using the `jj log` command. The output is formatted with the commit ID followed by the change ID and a newline character. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_55 LANGUAGE: sh CODE: ``` jj log --no-graph -T 'commit_id ++ " " ++ change_id ++ "\n"' ``` ---------------------------------------- TITLE: ChangeId Methods DESCRIPTION: Offers methods to format and retrieve different representations of a ChangeId, including its normal hex and shortest unique prefix. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_25 LANGUAGE: jj-vcs CODE: ``` `.normal_hex() -> String` .short([len: Integer]) -> String .shortest([min_len: Integer]) -> ShortestIdPrefix ``` ---------------------------------------- TITLE: jj Function: remote_bookmarks() DESCRIPTION: The remote_bookmarks() function returns all remote bookmark targets across all remotes. Optional bookmark and remote patterns can filter the results. Git-tracking bookmarks are not included. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_30 LANGUAGE: jj CODE: ``` remote_bookmarks() remote_bookmarks(bookmark_pattern) remote_bookmarks(bookmark_pattern, remote_pattern) remote_bookmarks(bookmark_pattern, remote=remote_pattern) remote_bookmarks(remote=remote_pattern) ``` ---------------------------------------- TITLE: Show commits by author and description keyword DESCRIPTION: This jj-vcs shell command filters commits by a specific author ('martinvonz') and a keyword ('reset') in their description. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_79 LANGUAGE: shell CODE: ``` jj log -r 'author(martinvonz) & description(reset)' ``` ---------------------------------------- TITLE: Jujutsu Template: Global Function - config DESCRIPTION: The 'config' function looks up a configuration value by its name. It takes a String name and returns a ConfigValue. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_20 LANGUAGE: Jujutsu Template CODE: ``` config(name: String) -> ConfigValue ``` ---------------------------------------- TITLE: Configure Rustfmt for Rust Formatting DESCRIPTION: This configuration enables Rustfmt, the official Rust code formatter, to format Rust files. It uses the `rustfmt --emit stdout --edition 2024` command and targets files matching the `**/*.rs` glob pattern. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/Fix-tools.md#_snippet_6 LANGUAGE: toml CODE: ``` [fix.tools.rustfmt] command = ["rustfmt", "--emit", "stdout", "--edition", "2024"] patterns = ["glob:'**/*.rs'"] ``` ---------------------------------------- TITLE: Parse jj log output to Nushell table DESCRIPTION: Defines a Nushell function `main` that retrieves `jj log` output, formats it based on specified columns, and parses it into a Nushell table. It handles column name sanitization and allows custom revsets. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/Nushell.md#_snippet_1 LANGUAGE: nushell CODE: ``` def to-group-name [] { str replace -ra "[()':,;|]" "" | str replace -ra '[".\-\s]' "_" } # Get the jj log as a table export def main [ --revset (-r): string ...columns: string ] { let columns = if ($columns | is-empty) { [change_id description "author.name()" "author.timestamp()"] } else { $columns } let parser = $columns | each { "{($in | to-group-name)}" } | str join (char fs) ( jj log ...(if $revset != null {[-r $revset]} else {[]}) --no-graph -T "{($columns | str join "++'(char fs)'++") ++ '(char rs)'}" ) | str trim --right --char (char rs) | split row (char rs) | parse $parser } ``` ---------------------------------------- TITLE: TreeDiff Methods DESCRIPTION: Details the methods for the TreeDiff type, including retrieving changed files, formatting diffs with color or Git format, and calculating statistics. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_47 LANGUAGE: any CODE: ``` TreeDiff.files() TreeDiff.color_words([context: Integer]) TreeDiff.git([context: Integer]) TreeDiff.stat([width: Integer]) TreeDiff.summary() ``` ---------------------------------------- TITLE: Reset gh-pages bookmark DESCRIPTION: Resets the local 'gh-pages' bookmark to match the upstream 'gh-pages' branch, discarding any local changes. This is useful for synchronizing with the remote repository. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/contributing.md#_snippet_20 LANGUAGE: git CODE: ``` jj git fetch --remote upstream jj bookmark set gh-pages -r gh-pages@upstream jj git push --remote origin --bookmark gh-pages ``` ---------------------------------------- TITLE: jj Git Push for Updating Branches DESCRIPTION: This command shows how to push a range of commits, typically a stack, to update corresponding branches on a remote repository. It's useful for pushing multiple related changes at once. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/sapling-comparison.md#_snippet_1 LANGUAGE: jj CODE: ``` jj git push -r main..@ ``` ---------------------------------------- TITLE: Configure Vim as Diff Tool (DirDiff Plugin) DESCRIPTION: This bash script sets up `vimdiff` using the DirDiff plugin for comparing directories. It shells-escapes paths and optionally sets a colorscheme. The script is designed to be executable and used with `jj`'s diff editor configuration. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/Vim,-Neovim.md#_snippet_0 LANGUAGE: bash CODE: ``` #!/bin/bash # On Mac OS, you may need to replace /bin/bash with /bin/zsh. # Shell-escape each path: DIR1=$(printf '%q' "$1"); shift DIR2=$(printf '%q' "$1"); shift # Setting the colorscheme is optional vim "$@" -c "colorscheme murphy" -c "DirDiff $DIR1 $DIR2" ``` ---------------------------------------- TITLE: CryptographicSignature Status and Key DESCRIPTION: Allows checking the status, key ID, and display string of a cryptographic signature. Be aware that these operations can be slow due to signature verification, although results are cached for consecutive calls. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_29 LANGUAGE: Rust CODE: ``` cryptographic_signature.status() cryptographic_signature.key() cryptographic_signature.display() ``` ---------------------------------------- TITLE: View Differences DESCRIPTION: Shows the differences between the current state and a specified state, useful when inspecting repository history. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/operation-log.md#_snippet_7 LANGUAGE: bash CODE: ``` jj diff ``` ---------------------------------------- TITLE: Show important commits (tags or bookmarks) DESCRIPTION: This jj-vcs shell command shows commits that are either tagged or bookmarked, similar to 'git --simplify-by-decoration'. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_77 LANGUAGE: shell CODE: ``` jj log -r 'tags() | bookmarks()' ``` ---------------------------------------- TITLE: ListTemplate Join Operation DESCRIPTION: Allows joining elements of a `ListTemplate` with a specified separator, returning a `Template`. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_34 LANGUAGE: Rust CODE: ``` list_template.join(separator) ``` ---------------------------------------- TITLE: Edit Commit Changes with jj diffedit DESCRIPTION: Demonstrates using `jj diffedit` to modify the changes within a specific commit without checking it out. This command can lead to conflicts in descendant commits. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/tutorial.md#_snippet_23 LANGUAGE: shell CODE: ``` $ jj diffedit -r @- Hint: Using default editor ':builtin'; run `jj config set --user ui.diff-editor :builtin` to disable this message. Rebased 1 descendant commits Working copy (@) now at: mrxqplyk 1c72cd50 (conflict) ABCD Parent commit (@-) : kwtuwqnm 70985eaa ABC Added 0 files, modified 1 files, removed 0 files Warning: There are unresolved conflicts at these paths: file 2-sided conflict New conflicts appeared in 1 commits: mrxqplyk 1c72cd50 (conflict) ABCD Hint: To resolve the conflicts, start by creating a commit on top of the conflicted commit: jj new mrxqplyk Then use `jj resolve`, or edit the conflict markers in the file directly. Once the conflicts are resolved, you can inspect the result with `jj diff`. Then run `jj squash` to move the resolution into the conflicted commit. ``` ---------------------------------------- TITLE: Jujutsu: Splitting Working Copy Changes DESCRIPTION: This demonstrates how to achieve the functionality of Git's `git add -p; git commit` in Jujutsu. Instead of staging parts of changes, Jujutsu uses `jj split` to divide the working copy into multiple commits. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/git-comparison.md#_snippet_0 LANGUAGE: Jujutsu CODE: ``` jj split ``` ---------------------------------------- TITLE: VisualJJ VS Code Plugin for Jujutsu DESCRIPTION: VisualJJ is a Visual Studio Code plugin offering native integration for Jujutsu, without relying on Git colocation. It provides a seamless experience for Jujutsu users within the VS Code environment. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/community_tools.md#_snippet_7 LANGUAGE: typescript CODE: ``` // VisualJJ is a VS Code extension. // Installation is done via the VS Code Marketplace. // The extension provides UI elements and commands for Jujutsu integration. ``` ---------------------------------------- TITLE: View Commit History with jj log DESCRIPTION: Displays the commit history, showing the current commit and the root commit. This is useful for identifying the commit you want to modify. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/FAQ.md#_snippet_9 LANGUAGE: console CODE: ``` $ jj log @ lnvvtrzo jjfan@example.com 2025-02-28 21:01:10 31a347e0 │ featureA ◆ zzzzzzzz root() 00000000 ``` ---------------------------------------- TITLE: Show local commits and their descendants DESCRIPTION: This jj-vcs shell command displays local commits leading up to the working copy, along with their descendants. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_78 LANGUAGE: shell CODE: ``` jj log -r '(remote_bookmarks()..@)::' ``` ---------------------------------------- TITLE: Snapshot Conflict Marker Style DESCRIPTION: Demonstrates the 'snapshot' conflict marker style, which displays the contents of each side of the conflict without explicit diff information. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/conflicts.md#_snippet_1 LANGUAGE: text CODE: ``` <<<<<<<< Conflict 1 of 1 +++++++ Contents of side #1 apple grapefruit orange ------- Contents of base apple grape orange +++++++ Contents of side #2 APPLE GRAPE ORANGE >>>>>>> Conflict 1 of 1 ends ``` ---------------------------------------- TITLE: Configure Mergiraf Merge Tool in JJ DESCRIPTION: This TOML configuration sets up Mergiraf as a merge tool within the `jj` version control system. It specifies the program to execute (`mergiraf`), the arguments for the merge operation, and the exit codes that indicate a merge conflict. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/Mergiraf.md#_snippet_0 LANGUAGE: TOML CODE: ``` [merge-tools.mergiraf] program = "mergiraf" merge-args = ["merge", "$base", "$left", "$right", "-o", "$output", "-l", "$marker_length", "--fast"] merge-conflict-exit-codes = [1] ``` ---------------------------------------- TITLE: Configure Micro as JJ Editor (Bash) DESCRIPTION: This command adds Micro as the default editor for JJ by modifying the user's JJ configuration. JJ will then use Micro to open change descriptions and configuration files. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/Micro.md#_snippet_0 LANGUAGE: bash CODE: ``` jj config edit --user --config-toml 'ui-editor="micro"' ``` ---------------------------------------- TITLE: Restore File Version with jj restore DESCRIPTION: Use 'jj restore' to choose one side of a conflict. Currently, there isn't a way to see the origin of the different parts of a conflict. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/working-copy.md#_snippet_7 LANGUAGE: bash CODE: ``` jj restore ``` ---------------------------------------- TITLE: Annotate functionality DESCRIPTION: Placeholder for documentation related to the 'Annotate' functionality within jj-vcs. This section is marked as 'TBD' (To Be Determined). SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/design/copy-tracking.md#_snippet_18 ---------------------------------------- TITLE: Handle multiple copies with rebasing DESCRIPTION: Illustrates a scenario with multiple file copies and a rebase operation. It shows how rebasing a commit with multiple copies onto another commit can lead to a 4-sided conflict if all changes apply to the same file. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/design/copy-tracking.md#_snippet_11 LANGUAGE: console CODE: ``` N foo="N" | | M foo="M, foo2=\"M2\", foo3=\"M3\"" | | | L copy foo->foo2, copy foo->foo3 |/ K add foo="K" ``` ---------------------------------------- TITLE: Jujutsu Template: Global Function - stringify DESCRIPTION: The 'stringify' function formats content to a string, effectively removing color labels. It accepts any Stringify input. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_13 LANGUAGE: Jujutsu Template CODE: ``` stringify(content: Stringify) -> String ``` ---------------------------------------- TITLE: Create New Revision on Remote Bookmark DESCRIPTION: Creates a new revision based on the state of a bookmark as recorded from a specific remote. This allows referencing remote bookmark states. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/bookmarks.md#_snippet_5 LANGUAGE: jj CODE: ``` jj new main@origin ``` ---------------------------------------- TITLE: CommitRef Methods DESCRIPTION: Provides methods to access information about a commit reference, such as its name, remote tracking status, and target commits. It also allows checking for conflicts and tracking status. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_27 LANGUAGE: Rust CODE: ``` commit_ref.name() commit_ref.remote() commit_ref.present() commit_ref.conflict() commit_ref.normal_target() commit_ref.removed_targets() commit_ref.added_targets() commit_ref.tracked() commit_ref.tracking_present() commit_ref.tracking_ahead_count() commit_ref.tracking_behind_count() ``` ---------------------------------------- TITLE: JJ Design Session: Command Set Rationalization DESCRIPTION: A session dedicated to rationalizing JJ's command set and options. It addresses the potential overlap and clarity issues with commands like squash, split, commit, restore, and their various flags and arguments. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/JJ-Con-2025.md#_snippet_10 LANGUAGE: English CODE: ``` **Command set**: If you look at jj {squash,split,commit,restore} combined with partial flags (--interactive, filesets) combined with -A/-B/--into etc., it's unclear whether the functionality is cleanly broken down into different commands anymore. This would be a session to rationalize the command set and available options. ``` ---------------------------------------- TITLE: Find Commits by Subject DESCRIPTION: This function finds commits whose subject (the first line of the description) matches a given string pattern. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_44 LANGUAGE: none CODE: ``` subject(pattern) ``` ---------------------------------------- TITLE: Check if Revset Exists DESCRIPTION: This function evaluates to `none()` if any of the commits in `x` doesn't exist (e.g. is an unknown bookmark name.) Otherwise, it returns the same as `x`. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_59 LANGUAGE: none CODE: ``` present(x) ``` ---------------------------------------- TITLE: Revert Merge Commit Changes in Jujutsu DESCRIPTION: Explains how to revert the changes introduced by a merge commit. Instead of using 'jj revert', it recommends using 'jj restore --from ' to create a new commit that undoes the merge. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/FAQ.md#_snippet_19 LANGUAGE: console CODE: ``` jj restore --from B jj desc -m "Revert the merge of D into B" ``` ---------------------------------------- TITLE: Fish Completion Script for JJ Revision Selection DESCRIPTION: This is a fish shell completion script that utilizes fzf to allow users to select a revision and insert its identifier into the command they are currently typing. This enhances the command-line workflow for jj users. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/fzf.md#_snippet_3 LANGUAGE: fish CODE: ``` A fish completion script using fzf, allowing you to select a revision and insert its id in the command you are currently typing: https://gist.github.com/tdaron/f5d0985687d8aed06714c8901dfb5fcb ``` ---------------------------------------- TITLE: Jujutsu Split Revision Excluding Foo DESCRIPTION: Illustrates splitting a revision into two, with the file 'foo' being placed into the second commit. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/filesets.md#_snippet_2 LANGUAGE: shell CODE: ``` jj split '~foo' ``` ---------------------------------------- TITLE: Track Remote Bookmark DESCRIPTION: Manually initiates tracking for a remote bookmark, creating a local bookmark that synchronizes with the remote counterpart. This command is used to establish the link between local and remote bookmarks. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/bookmarks.md#_snippet_6 LANGUAGE: jj CODE: ``` jj bookmark track mybookmark@origin ``` ---------------------------------------- TITLE: Signature Details DESCRIPTION: Allows retrieval of the name, email, and timestamp associated with a Signature. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_39 LANGUAGE: jj CODE: ``` signature.name() -> String signature.email() -> Email signature.timestamp() -> Timestamp ``` ---------------------------------------- TITLE: Default Conflict Marker Style DESCRIPTION: Illustrates the default conflict marker style used by Jujutsu, showing how changes from base to side #1 and the contents of side #2 are presented. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/conflicts.md#_snippet_0 LANGUAGE: text CODE: ``` <<<<<<<< Conflict 1 of 1 %%%%%%% Changes from base to side #1 apple -grape +grapefruit orange +++++++ Contents of side #2 APPLE GRAPE ORANGE >>>>>>> Conflict 1 of 1 ends ``` ---------------------------------------- TITLE: JJ TUI OCaml Terminal UI for Jujutsu DESCRIPTION: JJ TUI is a terminal user interface for Jujutsu, developed in OCaml. It is designed to be unopinionated, and its creator welcomes feedback for improvements. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/community_tools.md#_snippet_3 LANGUAGE: ocaml CODE: ``` (* JJ TUI is an OCaml application. Specific usage commands would depend on its implementation. Example: jj-tui This would launch the terminal user interface. *) ``` ---------------------------------------- TITLE: JJ Design Session: Code Formatting Brainstorm DESCRIPTION: Explores opportunities to fundamentally improve code formatter usage in JJ. Considers normalizing formatting on snapshot and applying user preferences during file materialization for working copies, diffs, and merges. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/JJ-Con-2025.md#_snippet_8 LANGUAGE: English CODE: ``` **Code formatting brainstorm**: Do we have any opportunities to fundamentally improve the use of code formatters? Extreme examples include normalizing formatting upon snapshot and/or applying user formatting preferences when materializing file content for the working copy, diffs, merges etc. ``` ---------------------------------------- TITLE: Configure Rubocop for Ruby Linting and Formatting DESCRIPTION: This configuration sets up Rubocop, a linter and formatter for Ruby, to automatically correct code. It uses the `rubocop --autocorrect --stdin $path --stderr` command, referencing a `.rubocop.yml` configuration file. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/Fix-tools.md#_snippet_4 LANGUAGE: toml CODE: ``` [fix.tools.rubocop] command = ["rubocop", "--config", ".rubocop.yml", "--autocorrect", "--stdin", "$path", "--stderr"] patterns = ["glob:'**/*.rb'"] ``` ---------------------------------------- TITLE: jj at Google: Architecture and Future Plans DESCRIPTION: An overview of the architecture of jj at Google and its future development plans. This session will cover the internal workings and strategic direction of the project. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/JJ-Con-2025.md#_snippet_4 LANGUAGE: English CODE: ``` Architecture and future plans ``` ---------------------------------------- TITLE: Jujutsu Template: Global Function - hash DESCRIPTION: The 'hash' function computes a hash of the input content and returns its hexadecimal string representation. The input must be Stringify. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_10 LANGUAGE: Jujutsu Template CODE: ``` hash(content: Stringify) -> String ``` ---------------------------------------- TITLE: JJ Design Session: Topics Integration DESCRIPTION: A roundtable discussion on integrating 'Topics' into JJ in a user-friendly manner. Aims to reach consensus on the concept, potentially progressing Git interoperability, and discussing metadata-oriented vs. physical approaches. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/JJ-Con-2025.md#_snippet_9 LANGUAGE: English CODE: ``` **Topics**: This roundtable is about Topics and how to integrate them in a user-friendly way. Because there are some separate ideas floating around what they should be, so it'd be nice for the project to find some consensus on them. So we could progress on them for better Git interop. And since I'm here in person I bring the current v2 of the design doc as a starting point. Some major points of discussion probably will be my metadata oriented approach or something more physical since that is contested in the current PR. ``` ---------------------------------------- TITLE: Extract Version from Repository Metadata using Git DESCRIPTION: This snippet demonstrates how to extract version information from repository metadata using Git commands. It queries remote repository heads, filters by a specific Git reference (often set by Sourcehut's CI environment variable `$GIT_REF`), and extracts version numbers matching a semantic versioning pattern. It also includes a fallback for cases where no version is found. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/Sourcehut-(sr.ht)-builds.md#_snippet_0 LANGUAGE: Git CODE: ``` VERSION=$(git ls-remote | grep $(git ls-remote | grep $GIT_REF | cut -f1) | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+') [[ $VERSION == "" ]] && VERSION=dev-$(git ls-remote | grep $GIT_REF | cut -f1) ``` ---------------------------------------- TITLE: Fetch Submodule Commits with jj git fetch DESCRIPTION: This snippet describes how submodule commits would be fetched using the equivalent of `jj git fetch`. It also discusses the complexities of recursive fetches and how to handle missing submodule commits gracefully. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/design/git-submodule-storage.md#_snippet_0 LANGUAGE: bash CODE: ``` # Example of fetching submodule commits # This is a conceptual example, not executable code. # The actual implementation would involve jj commands. # jj git fetch --submodule ``` ---------------------------------------- TITLE: Clone a Git Repository with Jujutsu DESCRIPTION: Clones a remote Git repository into a new Jujutsu repository. By default, the remote is named 'origin', but this can be customized using the --remote flag. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/git-compatibility.md#_snippet_5 LANGUAGE: bash CODE: ``` jj git clone [] jj git clone https://github.com/octocat/Hello-World jj git clone https://github.com/octocat/Hello-World --remote my-origin ``` ---------------------------------------- TITLE: Configure Ediff as JJ Merge Tool DESCRIPTION: This configuration sets up `ediff` as the merge tool for JJ by defining its program and arguments in the `.jjconfig.toml` file. It specifies that `sh` should be used to execute `emacsclient` with the `ediff-merge-files-with-ancestor` command, passing the necessary file arguments. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/Emacs.md#_snippet_1 LANGUAGE: toml CODE: ``` [merge-tools.ediff] program = 'sh' merge-args = ['-c', 'emacsclient -c --eval "(ediff-merge-files-with-ancestor \"$0\" \"$1\" \"$2\" nil \"$3\")"', '$left', '$right', '$base', '$output'] ``` ---------------------------------------- TITLE: Configure shfmt for Shell Script Formatting DESCRIPTION: This configuration sets up `shfmt`, a shell script formatter, to format bash and zsh scripts. It uses the `shfmt --filename=$path` command and targets files matching the `**/*.sh` glob pattern. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/Fix-tools.md#_snippet_7 LANGUAGE: toml CODE: ``` [fix.tools.shfmt] command = ["shfmt", "--filename=$path"] patterns = ["glob:'**/*.sh'"] ``` ---------------------------------------- TITLE: Commit Methods DESCRIPTION: Defines methods for interacting with commit objects, including retrieving commit details, parent commits, author/committer information, and status flags. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_23 LANGUAGE: jj-vcs CODE: ``` `.description() -> String` .trailers() -> List .change_id() -> ChangeId .commit_id() -> CommitId .parents() -> List .author() -> Signature .committer() -> Signature .signature() -> Option .mine() -> Boolean .working_copies() -> List .current_working_copy() -> Boolean .bookmarks() -> List .local_bookmarks() -> List .remote_bookmarks() -> List .tags() -> List .git_refs() -> List .git_head() -> Boolean .divergent() -> Boolean .hidden() -> Boolean .immutable() -> Boolean .contained_in(revset: String) -> Boolean .conflict() -> Boolean .empty() -> Boolean .diff([files: String]) -> TreeDiff .files([files: String]) -> List .root() -> Boolean ``` ---------------------------------------- TITLE: Create New Commit with jj DESCRIPTION: Create a new commit on top of an existing one, which is useful for resolving conflicts. The conflicts will be present in the new working-copy commit. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/working-copy.md#_snippet_2 LANGUAGE: bash CODE: ``` jj new ``` ---------------------------------------- TITLE: VJJ: JJ TUI with FZF DESCRIPTION: VJJ is a text-based user interface for the jj version control system, built using fzf. It provides an alternative TUI experience for managing jj repositories. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/fzf.md#_snippet_2 LANGUAGE: bash CODE: ``` ## VJJ A `jj` TUI based on fzf: https://github.com/noahmayr/vjj ``` ---------------------------------------- TITLE: jj Function: tracked_remote_bookmarks() DESCRIPTION: The tracked_remote_bookmarks() function returns all targets of tracked remote bookmarks, supporting the same optional arguments as remote_bookmarks(). SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_31 LANGUAGE: jj CODE: ``` tracked_remote_bookmarks() tracked_remote_bookmarks(bookmark_pattern) tracked_remote_bookmarks(bookmark_pattern, remote_pattern) tracked_remote_bookmarks(bookmark_pattern, remote=remote_pattern) tracked_remote_bookmarks(remote=remote_pattern) ``` ---------------------------------------- TITLE: Jujutsu Template: Global Function - truncate_start DESCRIPTION: The 'truncate_start' function truncates content by removing leading characters to fit a specified width. It takes width, content, and an optional ellipsis Template. The content should not contain newline characters. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_8 LANGUAGE: Jujutsu Template CODE: ``` truncate_start(width: Integer, content: Template, [ellipsis: Template]) ``` ---------------------------------------- TITLE: Displaying Elided Revisions in jj log DESCRIPTION: Demonstrates how to display elided revisions in the `jj log` output by using the `connected()` revset function. This is useful when a revset expression omits intermediate commits between two revisions. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/FAQ.md#_snippet_0 LANGUAGE: sh CODE: ``` jj log -r 'tyl|mus' ``` LANGUAGE: sh CODE: ``` jj log -r 'connected(tyl|mus)' ``` ---------------------------------------- TITLE: jj Function: untracked_remote_bookmarks() DESCRIPTION: The untracked_remote_bookmarks() function returns all targets of untracked remote bookmarks, supporting the same optional arguments as remote_bookmarks(). SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_32 LANGUAGE: jj CODE: ``` untracked_remote_bookmarks() untracked_remote_bookmarks(bookmark_pattern) untracked_remote_bookmarks(bookmark_pattern, remote_pattern) untracked_remote_bookmarks(bookmark_pattern, remote=remote_pattern) untracked_remote_bookmarks(remote=remote_pattern) ``` ---------------------------------------- TITLE: Track Untracked Files with jj DESCRIPTION: Use the 'jj file track' command to explicitly track files that were previously untracked. This is useful when the 'snapshot.auto-track' configuration is set to a non-default value. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/working-copy.md#_snippet_0 LANGUAGE: bash CODE: ``` jj file track ``` ---------------------------------------- TITLE: Jujutsu: Isolate local changes with separate commits DESCRIPTION: This section details a method to handle local-only changes to tracked files. It involves creating a separate commit for these changes and then merging it into the main branch when needed, preventing accidental pushes of sensitive or temporary modifications. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/FAQ.md#_snippet_8 LANGUAGE: shell CODE: ``` $ jj log @ xxxxxxxx me@example.com 2024-08-21 11:13:21 ef612875 │ Add new feature ◉ yyyyyyyy me@example.com 2024-08-21 11:13:09 main b624cf12 │ Existing work ~ ``` LANGUAGE: shell CODE: ``` $ jj new main -m "private: my credentials" Working copy (@) now at: wwwwwwww 861de9eb (empty) private: my credentials Parent commit (@-) : yyyyyyyy b624cf12 main | Existing work Added 0 files, modified 1 files, removed 0 files $ echo '{ "password": "p@ssw0rd1" }' > secret_config.json ``` LANGUAGE: shell CODE: ``` $ jj new xxxxxxxx wwwwwwww Working copy (@) now at: vvvvvvvv ac4d9fbe (empty) (no description set) Parent commit (@-) : xxxxxxxx ef612875 Add new feature Parent commit (@-) : wwwwwwww 2106921e private: my credentials Added 0 files, modified 1 files, removed 0 files $ jj log @ vvvvvvvv me@example.com 2024-08-22 08:57:40 ac4d9fbe ├─╮ (empty) (no description set) │ ◉ wwwwwwww me@example.com 2024-08-22 08:57:40 2106921e │ │ private: my credentials ◉ │ xxxxxxxx me@example.com 2024-08-21 11:13:21 ef612875 ├─╯ Add new feature ◉ yyyyyyyy me@example.com 2024-08-21 11:13:09 main b624cf12 │ Existing work ~ ``` LANGUAGE: shell CODE: ``` # Insert a new commit after xxxxxxxx $ jj new --no-edit -A xxxxxxxx -m "Another feature" Working copy (@) now at: uuuuuuuu 1c3cff09 (empty) Another feature Parent commit (@-) : xxxxxxxx ef612875 Add new feature # Insert a new commit between yyyyyyyy and vvvvvvvv $ jj new --no-edit -A yyyyyyyy -B vvvvvvvv -m "Yet another feature" Working copy (@) now at: tttttttt 938ab831 (empty) Yet another feature Parent commit (@-) : yyyyyyyy b624cf12 Existing work ``` ---------------------------------------- TITLE: Use Mergiraf with JJ Resolve DESCRIPTION: This command demonstrates how to use Mergiraf as the merge resolution tool with `jj resolve`. As of `jj` version 0.27.0, this command can be used without additional configuration. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/Mergiraf.md#_snippet_1 LANGUAGE: Shell CODE: ``` jj resolve --tool mergiraf ``` ---------------------------------------- TITLE: AnnotationLine Methods DESCRIPTION: Provides methods to access information about an annotation line, such as the responsible commit, line content, and line numbers. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_22 LANGUAGE: jj-vcs CODE: ``` `.commit() -> Commit` .content() -> Template .line_number() -> Integer .original_line_number() -> Integer .first_line_in_hunk() -> Boolean ``` ---------------------------------------- TITLE: Log Working Copy Parents with Short Commit IDs DESCRIPTION: Retrieves and displays the short commit IDs of the working copy's parents using the `jj log` command. It utilizes a custom template to format and join the parent commit IDs. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_54 LANGUAGE: sh CODE: ``` jj log --no-graph -r @ -T 'parents.map(|c| c.commit_id().short()).join(",")' ``` ---------------------------------------- TITLE: jj Function: none() DESCRIPTION: The none() function returns no commits and is provided for completeness, though rarely useful. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_26 LANGUAGE: jj CODE: ``` none() ``` ---------------------------------------- TITLE: Configure Prettier for Multiple File Types Formatting DESCRIPTION: This configuration enables Prettier, a popular formatter for JavaScript and related languages, to format a wide range of file types including JS, TS, JSON, HTML, Markdown, and CSS. It uses the `prettier --stdin-filepath $path` command. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/Fix-tools.md#_snippet_3 LANGUAGE: toml CODE: ``` [fix.tools.prettier] command = ["prettier", "--stdin-filepath", "$path"] patterns = [ "glob:'**/*.js'", "glob:'**/*.jsx'", "glob:'**/*.ts'", "glob:'**/*.tsx'", "glob:'**/*.json'", "glob:'**/*.html'", "glob:'**/*.md'", "glob:'**/*.css'", ] ``` ---------------------------------------- TITLE: Configure Terraform for HCL Formatting DESCRIPTION: This configuration integrates Terraform's built-in formatting capabilities for HCL files. It uses the `terraform fmt -` command to format files matching the `**/*.tf` glob pattern. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/Fix-tools.md#_snippet_8 LANGUAGE: toml CODE: ``` [fix.tools.terraform] command = ["terraform", "fmt", "-"] patterns = ["glob:'**/*.tf'"] ``` ---------------------------------------- TITLE: Create New Change with Jujutsu DESCRIPTION: Creates a new change based on a specified revision and updates the working copy. This is a fundamental step in branching or creating new features in Jujutsu. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/FAQ.md#_snippet_12 LANGUAGE: console CODE: ``` $ jj new b80 -m "featureB" Working copy (@) now at: pvnrkl 47171aa (empty) featureB Parent commit (@-) : lnvvtr?? b8004ab featureA ``` ---------------------------------------- TITLE: LazyJJ LazyGit-inspired TUI for Jujutsu DESCRIPTION: LazyJJ is a terminal user interface for Jujutsu, inspired by the design and functionality of lazygit. It provides a TUI experience for managing Jujutsu repositories. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/community_tools.md#_snippet_5 LANGUAGE: go CODE: ``` // lazyjj is a Go-based TUI application. // Usage typically involves running the compiled binary. // Example: lazyjj // This would launch the terminal user interface. ``` ---------------------------------------- TITLE: Add WSL Workspace in Jujutsu DESCRIPTION: This command adds a new Jujutsu workspace specifically for use within the Windows Subsystem for Linux (WSL) environment, helping to mitigate issues with WSL setting the execute bit on all files. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/windows.md#_snippet_3 LANGUAGE: PowerShell CODE: ``` PS> jj workspace add --name wsl ~/my-repo ``` ---------------------------------------- TITLE: Find Commits by Description DESCRIPTION: This function finds commits whose description matches a given string pattern. The description is usually terminated with a newline character. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_43 LANGUAGE: none CODE: ``` description(pattern) ``` ---------------------------------------- TITLE: ConfigValue Extraction DESCRIPTION: Enables extracting configuration values as different data types like boolean, integer, or a list of strings. Note that `as_string()` does not perform type conversion for non-string values. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_28 LANGUAGE: Rust CODE: ``` config_value.as_boolean() config_value.as_integer() config_value.as_string() config_value.as_string_list() ``` ---------------------------------------- TITLE: Restore Commit Contents with Jujutsu DESCRIPTION: Restores the contents of a specific commit into the working copy. This is useful when you need to re-apply changes from an older commit, potentially after creating a new branch or reverting. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/FAQ.md#_snippet_13 LANGUAGE: console CODE: ``` $ jj restore --from 31a347e0 Working copy (@) now at: pvnrkl 468104c featureB Parent commit (@-) : lnvvtr?? b8004ea featureA $ cat file Done with feature A Working on feature B ``` ---------------------------------------- TITLE: jj date matching patterns DESCRIPTION: Details the date matching patterns in jj-vcs, supporting 'after' and 'before' matching with various date string formats and relative times. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_69 LANGUAGE: jj CODE: ``` after:"2024-02-01" ``` LANGUAGE: jj CODE: ``` before:"2024-02-01" ``` LANGUAGE: jj CODE: ``` after:"2024-02-01T12:00:00" ``` LANGUAGE: jj CODE: ``` before:"2024-02-01T12:00:00-08:00" ``` LANGUAGE: jj CODE: ``` after:"2024-02-01 12:00:00" ``` LANGUAGE: jj CODE: ``` before:"2 days ago" ``` LANGUAGE: jj CODE: ``` after:"5 minutes ago" ``` LANGUAGE: jj CODE: ``` before:"yesterday" ``` LANGUAGE: jj CODE: ``` after:"yesterday 5pm" ``` LANGUAGE: jj CODE: ``` before:"yesterday 10:30" ``` LANGUAGE: jj CODE: ``` after:"yesterday 15:30" ``` ---------------------------------------- TITLE: Override trunk() alias in TOML DESCRIPTION: Demonstrates how to override the built-in 'trunk()' alias in jj-vcs by specifying a custom bookmark and remote in the revsets.toml configuration file. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_71 LANGUAGE: toml CODE: ``` [revset-aliases] 'trunk()' = 'your-bookmark@your-remote' ``` ---------------------------------------- TITLE: Email Parsing DESCRIPTION: Enables parsing email addresses to extract the local part (username) and the domain part. Handles cases where the email format might be irregular. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_31 LANGUAGE: Rust CODE: ``` email.local() email.domain() ``` ---------------------------------------- TITLE: Copy Tracking in JJ and Other VCSes DESCRIPTION: A survey of how other version control systems (VCSes) handle tracking file ancestry across copies and renames. It also details JJ's plans for implementing similar functionality. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/JJ-Con-2025.md#_snippet_1 LANGUAGE: English CODE: ``` A survey of how other VCSes have handled tracing ancestry of files across copies and renames, and our plans for doing the same in JJ ``` ---------------------------------------- TITLE: jj Function: connected() DESCRIPTION: The connected() function is equivalent to x::x and is useful when x includes several commits. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_24 LANGUAGE: jj CODE: ``` connected(x) ``` ---------------------------------------- TITLE: Visible Commits Query DESCRIPTION: Visible commits in Jujutsu can be viewed using the command `jj log -r 'all()'`. This command displays commits reachable from an anonymous head in the current view. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/glossary.md#_snippet_2 LANGUAGE: Jujutsu CLI CODE: ``` jj log -r 'all()' ``` ---------------------------------------- TITLE: Jujutsu Template: Operators DESCRIPTION: Jujutsu templates support various operators for method calls, arithmetic, logical operations, and string concatenation. Operator precedence is listed in order of binding strength. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_2 LANGUAGE: Jujutsu Template CODE: ``` x.f() ``` LANGUAGE: Jujutsu Template CODE: ``` -x ``` LANGUAGE: Jujutsu Template CODE: ``` !x ``` LANGUAGE: Jujutsu Template CODE: ``` x * y ``` LANGUAGE: Jujutsu Template CODE: ``` x / y ``` LANGUAGE: Jujutsu Template CODE: ``` x % y ``` LANGUAGE: Jujutsu Template CODE: ``` x + y ``` LANGUAGE: Jujutsu Template CODE: ``` x - y ``` LANGUAGE: Jujutsu Template CODE: ``` x >= y ``` LANGUAGE: Jujutsu Template CODE: ``` x > y ``` LANGUAGE: Jujutsu Template CODE: ``` x <= y ``` LANGUAGE: Jujutsu Template CODE: ``` x < y ``` LANGUAGE: Jujutsu Template CODE: ``` x == y ``` LANGUAGE: Jujutsu Template CODE: ``` x != y ``` LANGUAGE: Jujutsu Template CODE: ``` x && y ``` LANGUAGE: Jujutsu Template CODE: ``` x || y ``` LANGUAGE: Jujutsu Template CODE: ``` x ++ y ``` ---------------------------------------- TITLE: Find Working Copy Commits DESCRIPTION: This function identifies the working copy commits across all the workspaces. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_61 LANGUAGE: none CODE: ``` working_copies() ``` ---------------------------------------- TITLE: Find Commits by Author Date DESCRIPTION: This function finds commits with author dates matching the specified date pattern. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_48 LANGUAGE: none CODE: ``` author_date(pattern) ``` ---------------------------------------- TITLE: jj Function: git_head() DESCRIPTION: The git_head() function returns the Git HEAD target as of the last import. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_35 LANGUAGE: jj CODE: ``` git_head() ``` ---------------------------------------- TITLE: Edit Commit Description with jj describe DESCRIPTION: Allows editing the commit message of any commit using the `jj describe` command. This is part of Jujutsu's comprehensive support for rewriting history. SOURCE: https://github.com/jj-vcs/jj/blob/main/README.md#_snippet_2 LANGUAGE: Shell CODE: ``` jj describe ``` ---------------------------------------- TITLE: Push Bookmark to Git Remote DESCRIPTION: Pushes the state of a specified bookmark to a Git remote branch of the same name. This is used for synchronizing Jujutsu bookmarks with Git. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/bookmarks.md#_snippet_3 LANGUAGE: jj CODE: ``` jj git push --bookmark foo ``` ---------------------------------------- TITLE: Git-Style Conflict Marker Style DESCRIPTION: Shows the Git-style 'diff3' conflict markers supported by Jujutsu, which presents side #1, base, and side #2 content. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/conflicts.md#_snippet_2 LANGUAGE: text CODE: ``` <<<<<<<< Side #1 (Conflict 1 of 1) apple grapefruit orange ||||||| Base apple grape orange ======= APPLE GRAPE ORANGE >>>>>>> Side #2 (Conflict 1 of 1 ends) ``` ---------------------------------------- TITLE: Squash Changes into Commit with jj DESCRIPTION: Move conflict resolutions into the conflicted commit using the 'jj squash' command. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/working-copy.md#_snippet_4 LANGUAGE: bash CODE: ``` jj squash ``` ---------------------------------------- TITLE: jj Function: tags() DESCRIPTION: The tags() function returns all tag targets. An optional pattern can filter tags by name. Conflicted tags include all their possible targets. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_33 LANGUAGE: jj CODE: ``` tags() tags(pattern) ``` ---------------------------------------- TITLE: jj Function: all() DESCRIPTION: The all() function returns all visible commits and ancestors of commits explicitly mentioned. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_25 LANGUAGE: jj CODE: ``` all() ``` ---------------------------------------- TITLE: Convert Jujutsu Repo to Colocated Git Repo (Windows PowerShell) DESCRIPTION: Converts an existing Jujutsu repository into a colocated Jujutsu/Git repository using PowerShell on Windows. This process is similar to the Linux/macOS version but uses Set-Content to avoid issues with line endings in the git_target file. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/git-compatibility.md#_snippet_7 LANGUAGE: powershell CODE: ``` # Ignore the .jj directory in Git Set-Content -Path .jj/.gitignore -Value '/*' # Move the Git repo Move-Item -Path .jj/repo/store/git -Destination .git # Tell jj where to find it Set-Content -Path .jj/repo/store/git_target -Value '../../../.git' -NoNewline # Make the Git repository non-bare and set HEAD git config --unset core.bare # Convince jj to update .git/HEAD to point to the working-copy commit's parent jj new; jj undo ``` ---------------------------------------- TITLE: Sign Commits Automatically in Jujutsu DESCRIPTION: Allows for automatic signing of commits in Jujutsu. This can be configured via the `config.md` file or by using the `jj sign` command directly. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/git-compatibility.md#_snippet_4 LANGUAGE: bash CODE: ``` jj sign ``` ---------------------------------------- TITLE: Define Default Working Copy Mapping (Rust) DESCRIPTION: This Rust code snippet defines the default no-op mapping for WorkingCopyPatterns, initializing it with a root path mapping that is recursive. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/design/sparse-v2.md#_snippet_5 LANGUAGE: rust CODE: ``` vec![WorkingCopyMapping { src_path: RepoPathBuf::root(), dst_path: WorkingCopyPathBuf::root(), recursive: true, }] ``` ---------------------------------------- TITLE: Jujutsu Template: Built-in Alias - hyperlink DESCRIPTION: The 'hyperlink' alias creates a clickable hyperlink using OSC8 escape sequences. It takes a URL and display text. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_21 LANGUAGE: Jujutsu Template CODE: ``` hyperlink(url, text) ``` ---------------------------------------- TITLE: Configure yamlfmt for YAML Formatting DESCRIPTION: This configuration sets up `yamlfmt` to format YAML files. It uses the `yamlfmt -in` command and targets files matching `.yml` or `.yaml` glob patterns. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/Fix-tools.md#_snippet_9 LANGUAGE: toml CODE: ``` [fix.tools.yamlfmt] command = ["yamlfmt", "-in"] patterns = ["glob:'**/*.yml'", "glob:'**/*.yaml'"] ``` ---------------------------------------- TITLE: Jujutsu Template: Global Function - pad_end DESCRIPTION: The 'pad_end' function pads content by adding trailing fill characters to achieve a specified width. It takes width, content, and an optional fill character as Templates. The content should not contain newline characters. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_6 LANGUAGE: Jujutsu Template CODE: ``` pad_end(width: Integer, content: Template, [fill_char: Template]) ``` ---------------------------------------- TITLE: Git Command for Copy Detection DESCRIPTION: This command is used to find file copies within a Git repository, with options to adjust the search depth and intensity. It can be computationally expensive for large repositories. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/design/copy-tracking.md#_snippet_19 LANGUAGE: bash CODE: ``` git log --summary --find-copies-harder ``` ---------------------------------------- TITLE: Restore Submodule State with jj op restore DESCRIPTION: This section details how `jj op restore` would function with submodules stored as full repos. Each submodule maintains its own operation log, and superproject operations trigger corresponding submodule operations. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/design/git-submodule-storage.md#_snippet_1 LANGUAGE: bash CODE: ``` # Example of restoring a submodule state # This is a conceptual example, not executable code. # The actual implementation would involve jj commands. # jj op restore --revision ``` ---------------------------------------- TITLE: Find Commits by Author DESCRIPTION: This function finds commits where the author's name or email matches a given string pattern. It's equivalent to `author_name(pattern) | author_email(pattern)`. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_45 LANGUAGE: none CODE: ``` author(pattern) ``` ---------------------------------------- TITLE: Find Commits by Diff Content DESCRIPTION: This function finds commits containing diffs matching the given text pattern line by line. The search paths can be narrowed by the `files` expression. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_57 LANGUAGE: none CODE: ``` diff_contains(text, [files]) ``` ---------------------------------------- TITLE: Edit with Revset - Jujutsu DESCRIPTION: The `jj edit` command expects a revset that resolves to a single commit. It is an error to pass a revset that resolves to more than one commit or zero commits. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_0 LANGUAGE: bash CODE: ``` jj edit ``` ---------------------------------------- TITLE: JJ-FZF Bash Script for JJ Version Control DESCRIPTION: JJ-FZF is a bash shell script that provides a text UI for jj version control using fzf. It displays jj log with previews for diffs or obslogs and allows for quick revision actions like squashing, swapping, rebasing, and more. It also includes a view for the operations log to easily undo jj operations. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/fzf.md#_snippet_0 LANGUAGE: bash CODE: ``` ## JJ-FZF [JJ-FZF](https://github.com/tim-janik/jj-fzf) is a text UI for `jj` based on `fzf`, implemented as a bash shell script. The main view centers around `jj log`, providing previews for the diff or obslog of every revision. Several key bindings are available to quickly perform actions such as squashing, swapping, rebasing, splitting, branching, committing, or abandoning revisions. A separate view for the operations log enables fast previews of old commit histories or diffs between operations, making it easy to undo any `jj` operation. The available hotkeys are always displayed onscreen for simple discoverability. ``` ---------------------------------------- TITLE: Jujutsu Template: Global Function - pad_centered DESCRIPTION: The 'pad_centered' function pads content with leading and trailing fill characters to center it within a specified width. It accepts width, content, and an optional fill character as Templates. The content should not contain newline characters. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/templates.md#_snippet_7 LANGUAGE: Jujutsu Template CODE: ``` pad_centered(width: Integer, content: Template, [fill_char: Template]) ``` ---------------------------------------- TITLE: Find Commits by Author Name DESCRIPTION: This function finds commits where the author's name matches a given string pattern. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_46 LANGUAGE: none CODE: ``` author_name(pattern) ``` ---------------------------------------- TITLE: Find Commits by Author Email DESCRIPTION: This function finds commits where the author's email matches a given string pattern. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_47 LANGUAGE: none CODE: ``` author_email(pattern) ``` ---------------------------------------- TITLE: Abandon a Commit with jj abandon DESCRIPTION: Removes a commit from the repository's history. This command hides the specified commit and rebases any descendant commits onto its parent. Use with caution as it modifies the repository's state. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/tutorial.md#_snippet_16 LANGUAGE: shell CODE: ``` jj abandon ovknlmro ``` ---------------------------------------- TITLE: Jujutsu Diff Excluding Cargo.lock DESCRIPTION: Demonstrates how to use the fileset language to exclude a specific file, 'Cargo.lock', when viewing differences. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/filesets.md#_snippet_0 LANGUAGE: shell CODE: ``` jj diff '~Cargo.lock' ``` ---------------------------------------- TITLE: JJ Design Session: Filtering and Transforming Commit Graphs DESCRIPTION: Discussion on a generalized 'filter' tool for transforming commit graphs in JJ. Explores use cases like subproject import/export and design questions regarding filter invertibility and Change-IDs. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/JJ-Con-2025.md#_snippet_6 LANGUAGE: English CODE: ``` **Filtering and transforming commit graphs**: Discuss some ideas about a generalized 'filter' tool that can perform transormations on the commit graph to produce new commit graphs. The most common case for this is importing and exporting subprojects, but in theory many arbitrary transformations are usable. The biggest design questions I have is if filters should be "invertible" or not, how Change-IDs should work, etc. It would be good to know some use cases to scope things appropriately. ``` ---------------------------------------- TITLE: Configure FileMerge for jj (Mac XCode) DESCRIPTION: This TOML configuration sets up FileMerge, launched via the 'open' command, as the merge tool for jj. It specifies arguments for both editing and merging, including placeholders for left, right, output, and base files. Note that jj will only proceed after FileMerge is fully quit. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/MacOS‐specific-tools.md#_snippet_0 LANGUAGE: TOML CODE: ``` [merge-tools.filemerge] # Note: You have to fully exit FileMerge for `jj` to move on. program = "open" edit-args = ["-a", "FileMerge", "-n", "-W", "--args", "-left", "$left", "-right", "$right", "-merge", "$output"] merge-args = ["-a", "FileMerge", "-n", "-W", "--args", "-left", "$left", "-right", "$right", "-ancestor", "$base", "-merge", "$output"] ``` ---------------------------------------- TITLE: jj Function: git_refs() DESCRIPTION: The git_refs() function returns all Git ref targets as of the last import. Conflicted Git refs include all their possible targets. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_34 LANGUAGE: jj CODE: ``` git_refs() ``` ---------------------------------------- TITLE: JJ Design Session: Tagging DESCRIPTION: A design session focused on handling tagging in JJ, ensuring compatibility beyond the Git backend. It addresses pinning names to commits and managing changes to tagged revisions. SOURCE: https://github.com/jj-vcs/jj/blob/main/__wiki__/JJ-Con-2025.md#_snippet_5 LANGUAGE: English CODE: ``` **Tagging**: Figure out how to handle tagging and not just specifically for the git backend. It's useful to be able to pinpoint a name to a specific commit (essentially bookmarks but for commits and inherently immutable). My main open question is handling changes in the revision the commit belongs to, be it through simple amendments/squashes or rebases of entire commit trees ``` ---------------------------------------- TITLE: Move Changes Between Commits with jj squash DESCRIPTION: Moves part of the changes from one commit to another using the `jj squash` command with interactive options. This facilitates reorganizing commit content. SOURCE: https://github.com/jj-vcs/jj/blob/main/README.md#_snippet_5 LANGUAGE: Shell CODE: ``` jj squash -i --from --into ``` ---------------------------------------- TITLE: Convert Jujutsu Repo to Colocated Git Repo (Linux/macOS) DESCRIPTION: Converts an existing Jujutsu repository into a colocated Jujutsu/Git repository. This involves creating a .gitignore for the .jj directory, moving the Git store, and updating Jujutsu's configuration. Note: This is not officially supported and has platform-specific considerations. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/git-compatibility.md#_snippet_6 LANGUAGE: bash CODE: ``` # Ignore the .jj directory in Git echo '/*' > .jj/.gitignore # Move the Git repo mv .jj/repo/store/git .git # Tell jj where to find it (do not use on Windows! See below.) echo -n '../../../.git' > .jj/repo/store/git_target # Make the Git repository non-bare and set HEAD git config --unset core.bare # Convince jj to update .git/HEAD to point to the working-copy commit's parent jj new && jj undo ``` ---------------------------------------- TITLE: Track a Remote Bookmark DESCRIPTION: Permanently track a remote bookmark to have it imported as a local bookmark. This command ensures that subsequent fetches from the specified remote will update the local bookmark. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/bookmarks.md#_snippet_8 LANGUAGE: sh CODE: ``` jj bookmark track @ ``` ---------------------------------------- TITLE: GitBackend Ref Management in Jujutsu DESCRIPTION: The GitBackend in Jujutsu manages Git repository commits and refs using libgit2. To prevent garbage collection from removing commits still referenced by the operation log, it creates refs for each commit in the operation log under the 'refs/jj/keep/' namespace. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/technical/architecture.md#_snippet_0 LANGUAGE: Rust CODE: ``` The `GitBackend` stores a ref for each commit in the operation log in the `refs/jj/keep/` namespace. ``` ---------------------------------------- TITLE: jj Function: first_parent() DESCRIPTION: The first_parent() function is similar to parents(), but for merge commits, it only returns the first parent. The depth argument works similarly, so first_parent(x, 2) is equivalent to first_parent(first_parent(x)). SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_21 LANGUAGE: jj CODE: ``` first_parent(x) first_parent(x, depth) ``` ---------------------------------------- TITLE: View Repository Status DESCRIPTION: Displays the current status of the repository, which can help identify conflicts arising from concurrent operations. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/operation-log.md#_snippet_5 LANGUAGE: bash CODE: ``` jj st ``` ---------------------------------------- TITLE: jj Operator: ::x (Ancestors) DESCRIPTION: The `::x` operator selects the ancestors of the commits in revset `x`, including the commits in `x` itself. It's a shorthand for `root()::x`. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_7 LANGUAGE: jj CODE: ``` ::D ⇒ {D,C,B,A,root()} ::B ⇒ {B,A,root()} ::A ⇒ {A,root()} ::root() ⇒ {root()} ::none() ⇒ {} ::(C|B) ⇒ {C,B,A,root()} ``` ---------------------------------------- TITLE: Find Empty Commits DESCRIPTION: This function identifies commits that modify no files. This also includes `merges()` without user modifications and `root()`. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/revsets.md#_snippet_55 LANGUAGE: none CODE: ``` empty() ``` ---------------------------------------- TITLE: Split a Commit with jj split DESCRIPTION: Splits a commit into two separate commits using the `jj split` command. This is useful for organizing commit history. SOURCE: https://github.com/jj-vcs/jj/blob/main/README.md#_snippet_4 LANGUAGE: Shell CODE: ``` jj split ``` ---------------------------------------- TITLE: Undo Last Operation with jj undo DESCRIPTION: Reverts the most recent operation performed on the repository. This command can be used to undo actions like squashing, snapshotting, or rebasing, and it updates the working copy accordingly. It may also introduce new conflicts. SOURCE: https://github.com/jj-vcs/jj/blob/main/docs/tutorial.md#_snippet_18 LANGUAGE: shell CODE: ``` $ jj undo Reverted operation: d3b77addea49 (2025-05-12 00:27:27) squash commits into f7fb5943a6b9460eb106dba2fac5cac1625c6f7a Working copy (@) now at: zxoosnnp 63874fe6 (no description set) Parent commit (@-) : puqltutt f7fb5943 (conflict) B2 New conflicts appeared in 2 commits: qzvqqupx 1978b534 (conflict) C puqltutt f7fb5943 (conflict) B2 Hint: To resolve the conflicts, start by creating a commit on top of the first conflicted commit: jj new puqltutt Then use `jj resolve`, or edit the conflict markers in the file directly. Once the conflicts are resolved, you can inspect the result with `jj diff`. Then run `jj squash` to move the resolution into the conflicted commit. $ jj log @ zxoosnnp martinvonz@google.com 2023-02-12 19:34:09 63874fe6 │ (no description set) │ × qzvqqupx martinvonz@google.com 2023-02-12 15:08:33 1978b534 conflict ├─╯ C × puqltutt martinvonz@google.com 2023-02-12 15:08:33 f7fb5943 conflict │ B2 │ ○ ovknlmro martinvonz@google.com 2023-02-12 15:07:24 7d7c6e6b ├─╯ B1 ○ nuvyytnq martinvonz@google.com 2023-02-12 15:07:05 5dda2f09 │ A │ ○ kntqzsqt martinvonz@google.com 2023-02-12 14:56:59 5d39e19d ├─╯ Say goodbye ◆ orrkosyo octocat@nowhere.com 2012-03-06 15:06:50 master 7fd1a60b │ (empty) Merge pull request #6 from Spaceghost/patch-1 ~ ```