Skip to main content

Module jj

Module jj 

Source
Expand description

Jj backend. Shells out only to the jj CLI (never raw git) plus the standalone patch(1) tool for applying diffs - a secondary jj workspace add’d directory has no .git of its own (only the canonical repo’s own default workspace is colocated with git), so git apply isn’t available there. jj commit snapshots the working copy directly, so patch(1) editing files on disk is enough; no index of any kind needs updating.

  • Checkout::Ref with a fork: jj git remote add <remote_name> <remote_url> (skipped if jj git remote list already has it - add isn’t idempotent), then jj git fetch -b <branch> --remote <remote_name>, giving the revset <branch>@<remote_name>.
  • Checkout::Ref with no fork (the PR’s source fork was deleted): unsupported for now - there’s no remote/branch left to track and no raw-git fallback per the above. Callers should suggest the git backend for that review instead.
  • Checkout::Patches: base must already be reachable (fetched as part of some branch’s history) - the jj backend has no by-SHA fetch to fall back on; None resolves to jj’s own trunk() revset alias.
  • add_workspace/update_workspace: jj workspace add --name rq-<name> -r <revset> <ws> / jj new <revset> (run from inside ws), then each patch is applied with patch -p1 and jj commit -m. jj stamps a commit’s author when it’s created as an empty node, not when jj commit later finalizes it - so authors are pre-stamped one step ahead via --config user.name=.../user.email=... on whichever call creates the commit that will receive that patch (the initial workspace add/new for the first patch, the previous patch’s commit for the rest). Verified with a local spike before relying on it.
  • Every add_workspace/update_workspace call pins its resulting head under a review-queue/<name>/<version> bookmark (jj bookmark create/set). This isn’t optional bookkeeping the way it might seem: a spike showed that without it, a force-pushed PR branch causes jj git fetch to abandon the old head on re-fetch (git.abandon-unreachable-commits defaults to true), breaking interdiffing. The pin keeps it reachable regardless of what the remote branch does next.
  • is_dirty: @ isn’t empty, or @- isn’t the expected id (the stack tip) or one of its ancestors.
  • position: jj new <commit> (never edit, which would rewrite the stack).
  • remove_workspace: jj workspace forget, rm -rf, and delete every review-queue/<name>/* bookmark.

Structs§

JjVcs