13 fsmonitor.watchman.register-snapshot-trigger = true;
17 max-new-file-size = "2MiB";
18 auto-update-stale = true;
30 "(trunk()..@):: | (trunk()..@)-"
32 #l = ["log" "-r" "more()"];
37 # Figures out the closest bookmark
38 # and pulls it up to the latest change that can be pushed.
61 ]; # commit interactive
90 ]; # describe previous
100 "git_format_patch_email_headers"
132 ]; # new bookmark (for creating bookmark to push)
138 ]; # new change before
171 jj bookmark move --from "closest_bookmark(@)" --to "closest_pushable(@)"
173 jj bookmark move --to "closest_pushable(@)" "$@"
184 "jj up && jj git push"
195 gh pr view --json headRepository,headRefName,headRepositoryOwner $PR --jq '"
197 jj 2>/dev/null git remote add \"$1\" \"$2\" ||
198 jj git remote set-url \"$1\" \"$2\"
200 set_remote \(.headRepositoryOwner.login) git@github.com:\(.headRepositoryOwner.login)/\(.headRepository.name)
201 jj git fetch --remote \(.headRepositoryOwner.login) --branch \(.headRefName)
202 jj bookmark track --remote=\(.headRepositoryOwner.login) \(.headRefName)
203 origin=$(gh repo view --json owner,name --jq .owner.login)
204 set_remote \"$origin\" \"$(gh repo view --json sshUrl --jq .sshUrl)\"
205 git fetch --force --update-head-ok \"$origin\" \"refs/pull/'"$PR"'/head:refs/remotes/$origin/pull/'"$PR"'\"
211 untrack-github-PR = [
219 gh pr view --json headRepository,headRefName,headRepositoryOwner $PR --jq '"
220 jj bookmark forget \(.headRefName) || true
221 origin=$(gh repo view --json owner,name --jq .owner.login)
222 git for-each-ref --format \"delete %(refname)\" \\
223 \"refs/remotes/\(.headRepositoryOwner.login)/\(.headRefName)\" \\
224 \"refs/remotes/$origin/pull/'"$PR"'\" |
226 git update-ref --stdin
230 "jj-untrack-github-PR"
232 # Get all open stacks of work.
243 # Retrunk a series. Typically used as `jj retrunk -s ...` and notably can be
245 # - jj retrunk -s 'all:roots(open())'
251 # Retrunk the current stack of work.
257 "all:roots(trunk()..stack(@))"
259 # Take content from any change and move it into @.
260 # - jj consume xyz path/to/file`
267 # Eject content from @ into any other change.
268 # - jj eject xyz --interactive
280 # All operations, with more whitespace
285 "builtin_op_log_comfortable"
291 "description(exact:'') ~ root()"
293 # Move $commit just after the bookmark, and then move $bookmark on top of it.
295 # "$bookmark+" works, because after rebase -A, the only child of $bookmark is $commit.
296 # I do not use $commit itself because it might point to a
297 # different commit after the rebase (e.g. @-).
299 # My workflow uses mega-merge: I write a commit or two,
300 # and then move them to relevant branches with jj to.
301 # As a bonus, bookmarks are kept up-to-date for easy pushing.
302 # https://github.com/jj-vcs/jj/discussions/5568#discussioncomment-14289564
313 # default to latest non-ephemeral commit
314 if [ -z "$commit" ]; then
315 commit=$(jj log --no-graph -T change_id -r '@ ~ ephemeral')
316 if [ -n "$commit" ]; then
317 # Moving current commit, create a new one to preserve
318 # current position in the commit DAG
324 jj rebase -r "$commit" -A "$bookmark"
325 jj bookmark move -f "$bookmark" -t "$bookmark+"
336 # Focus current commit, trunk(), on local work and remote work by removing ancestors of trunk()
338 "@ | trunk() | ancestors_and_children(bookmarks() | tracked_remote_bookmarks()) ~ ..trunk()";
340 "active(rev)" = "(ancestors(rev) | descendants(rev)) ~ immutable()";
341 "ancestors_and_children(x)" = "..x | x::";
343 # Remote commits not merged in trunk()
344 "review()" = "ancestors_and_children(@) ~ ..trunk()";
345 "review(x)" = "ancestors_and_children(remote_bookmarks(x)) ~ ..trunk()";
346 "reviews()" = "ancestors_and_children(remote_bookmarks()) ~ ..trunk()";
349 "wip()" = "ancestors_and_children(bookmarks()) ~ ..(remote_bookmarks() | trunk())";
350 "wip(x)" = "trunk() | ..bookmarks(x) ~ ..(remote_bookmarks() | trunk())";
352 # Authored or committed by specified user
353 "user(x)" = "author(x) | committer(x)";
355 "closest_tip()" = "heads(::@ & remote_bookmarks())";
357 # Those who would be abandoned if you check out something else
358 ephemeral = "(empty() ~ merges() ~ root()) & description(exact:\" \")";
360 # show everything in the current set of branches off of trunk():
361 branch = "(coalesce(trunk(),root())..@)- | (coalesce(trunk(),root())..@)::";
364 "closest_bookmark(to)" = "heads(::to & bookmarks())";
365 "closest_pushable(to)" =
366 "heads(::to & mutable() & ~description(exact:\" \") & (~empty() | merges()))";
368 "desc(x)" = "description(x)";
369 "pending()" = ".. ~ ::tags() ~ ::remote_bookmarks() ~ @ ~ private()";
371 "description(glob:'wip:*') | description(glob:'private:*') | description(glob:'WIP:*') | description(glob:'PRIVATE:*') | conflicts() | (empty() ~ merges()) | description('substring-i:\"DO NOT MAIL\"')";
372 #"trunk()" = "main@rad";
373 #"immutable_heads()" = "tags()";
374 "immutable_heads()" =
375 "present(trunk()) | tags() | ( untracked_remote_bookmarks() ~ untracked_remote_bookmarks(remote=glob:'rad') ~ untracked_remote_bookmarks(regex:'^patch(es)/',remote=glob:'rad'))";
376 #'default()' = 'coalesce(trunk(), root())::present(@) | ancestors(visible_heads(), 2)'
379 "bases" = "present(main@rad) | present(master@origin) | present(main@origin)";
380 "downstream(x,y)" = "(x::y) & y";
381 "branches" = "downstream(trunk(), bookmarks()) & mine()";
382 "branchesandheads" = "branches | (heads(trunk()::) & mine())";
383 "curbranch" = "latest(branches::@- & branches)";
384 "nextbranch" = "roots(@:: & branchesandheads)";
386 "more" = "log | ancestors(visible_heads(), 2)";
387 "unmerged()" = "bookmarks() & ~(trunk():: | trunk())";
388 "recent()" = "committer_date(after:\"1 months ago\")";
389 "recent(revset)" = "revset & recent()";
391 # stack(x, n) is the set of mutable commits reachable from 'x', with 'n'
392 # parents. 'n' is often useful to customize the display and return set for
393 # certain operations. 'x' can be used to target the set of 'roots' to traverse,
394 # e.g. @ is the current stack.
395 "stack()" = "ancestors(reachable(@, mutable()), 2)";
396 "stack(x)" = "ancestors(reachable(x, mutable()), 2)";
397 "stack(x, n)" = "ancestors(reachable(x, mutable()), n)";
399 # The current set of "open" works. It is defined as:
401 # - given the set of commits not in trunk, that are written by me,
402 # - calculate the given stack() for each of those commits
404 # n = 1, meaning that nothing from `trunk()` is included, so all resulting
405 # commits are mutable by definition.
406 "open()" = "stack(trunk().. & mine(), 1)";
408 # the set of 'ready()' commits. defined as the set of open commits, but nothing
409 # that is blacklisted or any of their children.
411 # often used with gerrit, which you can use to submit whole stacks at once:
413 # - jj gerrit send -r 'ready()' --dry-run
414 "ready()" = "open() ~ blacklist()::";
418 # Hide unnecessary bits to make the jj log more concise
419 #"format_short_change_id(id)" = "id.shortest(4)"
420 #"format_short_commit_id(id)" = "id.shortest(4)"
421 "format_timestamp(timestamp)" = "timestamp.ago()";
423 #"format_short_signature(signature)" = "signature.email()"
424 # Both name and email address
425 #"format_short_signature(signature)" = "signature"
426 # Username part of the email address
427 #"format_short_signature(signature)" = "signature.email().local()"
428 "format_short_signature(signature)" = "signature.name()";
432 write-change-id-header = true;
433 # Prevent pushing work in progress or anything explicitly labeled "private";
434 private-commits = "description(glob:'wip:*') | description(glob:'private:*')";
435 # Don't require --allow-new when pushing a new bookmark
444 origin.auto-track-bookmarks = "glob:*";
445 ju1m.auto-track-bookmarks = "glob:*";
450 default-command = "log";
451 diff-editor = ":builtin";
452 # From https://github.com/julienvincent/hunk.nvim
453 #diff-editor = ["nvim", "-c", "DiffEditor $left $right $output"];
454 show-cryptographic-signatures = true;
457 merge-tools.diffconflicts = {
461 "let g:jj_diffconflicts_marker_length=$marker_length"
469 merge-tool-edits-conflict-markers = true;
472 # # via @dubi steinkek in the jj discord
473 # [merge-tools.gitpatch];
475 # edit-args = ["-c", '''
477 # rm -f "$right/JJ-INSTRUCTIONS"
478 # git -C "$left" init -q
479 # git -C "$left" add -A
480 # git -C "$left" commit -q -m baseline --allow-empty
481 # mv "$left/.git" "$right"
482 # git -C "$right" add --intent-to-add --ignore-removal . # tell git to include new files in interactive patch mode
483 # git -C "$right" add -p
484 # git -C "$right" diff-index --quiet --cached HEAD && { echo "No changes done, aborting split."; exit 1; }
485 # git -C "$right" commit -q -m split
486 # git -C "$right" reset -q --hard # undo changes in modified files, remove added files
489 # merge-args = ["-c", "echo gitpatch cannot be used as a diff tool"];
490 # diff-args = ["-c", "echo gitpatch cannot be used as a diff tool"];
493 home.packages = lib.mkIf config.programs.git.enable [
499 xdg.configFile."jjui".source = jujutsu/jjui;
500 programs.bash = lib.mkIf config.programs.git.enable {
503 jer = "jj-edit-review";
506 jj-edit () { local revs=$1; shift; $EDITOR $(jj diff -r "$revs" --name-only "$@"); }
507 jj-edit-review () { local revs=$1; shift; $EDITOR $(jj diff -r "review($revs)" --name-only "$@"); }