3 fsmonitor.watchman.register-snapshot-trigger = true
6 max-new-file-size = "2MiB"
7 auto-update-stale = true
12 l = ["log", "-r", "(trunk()..@):: | (trunk()..@)-"]
13 #l = ["log", "-r", "more()"]
14 fresh = ["new", "trunk()"]
15 # Figures out the closest bookmark
16 # and pulls it up to the latest change that can be pushed.
21 "closest_bookmark(@)",
23 "closest_pushable(@)",
25 bl = ["bookmark", "list"]
26 blr = ["bookmark", "list", "--revisions", "recent()"]
28 ci = ["commit", "--interactive"] # commit interactive
30 mm = ["describe", "--message"]
31 d = ["diff", "--stat", "--revisions"]
32 dd = ["diff", "--revisions"]
33 files = ["diff", "--name-only", "--revisions"]
34 review-files = ["diff", "--name-only", "--revisions", "review()"]
35 dp = ["describe", "@-"] # describe previous
37 para = [ "parallelize", "closest_tip()..@-" ]
38 patch = ["show", "--git", "--template", "git_format_patch_email_headers"]
39 pull = ["git", "fetch"]
40 push = ["git", "push"]
41 gf = ["git", "fetch"] # git fetchq
42 gi = ["git", "init", "--colocate"]
43 gp = ["git", "push"] # git push
44 i = ["git", "init", "--colocate"]
45 nb = ["bookmark", "create", "-r @-"] # new bookmark (for creating bookmark to push)
46 nc = ["new", "-B", "@", "--no-edit"] # new change before
48 rm = ["rebase", "-d", "main"] # "re-main"
49 s = ["show", "--stat"]
52 sqi = ["squash", "--interactive"]
53 si = ["squash", "--interactive"]
55 up = ["util", "exec", "--", "sh", "-c", """
57 jj bookmark move --from "closest_bookmark(@)" --to "closest_pushable(@)"
59 jj bookmark move --to "closest_pushable(@)" "$@"
62 upp = ["util", "exec", "--", "sh", "-c", "jj up && jj git push", ""]
64 track-github-PR = ["util", "exec", "--", 'sh', '-euxc', '''
66 gh pr view --json headRepository,headRefName,headRepositoryOwner $PR --jq '"
68 jj 2>/dev/null git remote add \"$1\" \"$2\" ||
69 jj git remote set-url \"$1\" \"$2\"
71 set_remote \(.headRepositoryOwner.login) git@github.com:\(.headRepositoryOwner.login)/\(.headRepository.name)
72 jj git fetch --remote \(.headRepositoryOwner.login) --branch \(.headRefName)
73 jj bookmark track \(.headRefName)@\(.headRepositoryOwner.login)
74 origin=$(gh repo view --json owner,name --jq .owner.login)
75 set_remote \"$origin\" \"$(gh repo view --json sshUrl --jq .sshUrl)\"
76 git fetch --force --update-head-ok \"$origin\" \"refs/pull/'"$PR"'/head:refs/remotes/$origin/pull/'"$PR"'\"
79 ''', "jj-track-github-PR"]
81 untrack-github-PR = ["util", "exec", "--", 'sh', '-euxc', '''
83 gh pr view --json headRepository,headRefName,headRepositoryOwner $PR --jq '"
84 jj bookmark forget \(.headRefName) || true
85 origin=$(gh repo view --json owner,name --jq .owner.login)
86 git for-each-ref --format \"delete %(refname)\" \\
87 \"refs/remotes/\(.headRepositoryOwner.login)/\(.headRefName)\" \\
88 \"refs/remotes/$origin/pull/'"$PR"'\" |
90 git update-ref --stdin
93 ''', "jj-untrack-github-PR"]
95 # Get all open stacks of work.
96 open = ["log", "-r", "open()"]
99 credit = ["file", "annotate"]
101 # Retrunk a series. Typically used as `jj retrunk -s ...`, and notably can be
103 # - jj retrunk -s 'all:roots(open())'
104 retrunk = ["rebase", "-d", "trunk()"]
106 # Retrunk the current stack of work.
107 reheat = ["rebase", "-d", "trunk()", "-s", "all:roots(trunk()..stack(@))"]
109 # Take content from any change, and move it into @.
110 # - jj consume xyz path/to/file`
111 consume = ["squash", "--into", "@", "--from"]
113 # Eject content from @ into any other change.
114 # - jj eject xyz --interactive
115 eject = ["squash", "--from", "@", "--into"]
120 # All operations, with more whitespace
121 oo = ["op", "log", "-T", "builtin_op_log_comfortable"]
123 abandon-empties = ["abandon", "-r", "description(exact:'') ~ root()"]
125 # Move $commit just after the bookmark, and then move $bookmark on top of it.
127 # "$bookmark+" works, because after rebase -A, the only child of $bookmark is $commit.
128 # I do not use $commit itself because it might point to a
129 # different commit after the rebase (e.g. @-).
131 # My workflow uses mega-merge: I write a commit or two,
132 # and then move them to relevant branches with jj to.
133 # As a bonus, bookmarks are kept up-to-date for easy pushing.
134 # https://github.com/jj-vcs/jj/discussions/5568#discussioncomment-14289564
135 to = ['util', 'exec', '--', 'sh', '-c', '''
141 # default to latest non-ephemeral commit
142 if [ -z "$commit" ]; then
143 commit=$(jj log --no-graph -T change_id -r '@ ~ ephemeral')
144 if [ -n "$commit" ]; then
145 # Moving current commit, create a new one to preserve
146 # current position in the commit DAG
153 jj rebase -r "$commit" -A "$bookmark"
154 jj bookmark move -f "$bookmark" -t "$bookmark+"
161 # Focus current commit, trunk(), on local work and remote work by removing ancestors of trunk()
162 "default()" = "@ | trunk() | ancestors_and_children(bookmarks() | tracked_remote_bookmarks()) ~ ..trunk()"
164 "active(rev)" = "(ancestors(rev) | descendants(rev)) ~ immutable()"
165 "ancestors_and_children(x)" = "..x | x::"
167 # Remote commits not merged in trunk()
168 "review()" = "ancestors_and_children(@) ~ ..trunk()"
169 "review(x)" = "ancestors_and_children(remote_bookmarks(x)) ~ ..trunk()"
170 "reviews()" = "ancestors_and_children(remote_bookmarks()) ~ ..trunk()"
173 "wip()" = "ancestors_and_children(bookmarks()) ~ ..(remote_bookmarks() | trunk())"
174 "wip(x)" = "trunk() | ..bookmarks(x) ~ ..(remote_bookmarks() | trunk())"
177 # Authored or committed by specified user
178 'user(x)' = 'author(x) | committer(x)'
180 'closest_tip()' = 'heads(::@ & remote_bookmarks())'
182 # Those who would be abandoned if you check out something else
183 ephemeral = '(empty() ~ merges() ~ root()) & description(exact:"")'
185 # show everything in the current set of branches off of trunk():
186 branch = '(coalesce(trunk(),root())..@)- | (coalesce(trunk(),root())..@)::'
189 'closest_bookmark(to)' = 'heads(::to & bookmarks())'
190 'closest_pushable(to)' = 'heads(::to & mutable() & ~description(exact:"") & (~empty() | merges()))'
192 "desc(x)" = "description(x)"
193 "pending()" = ".. ~ ::tags() ~ ::remote_bookmarks() ~ @ ~ private()"
194 "private()" = "description(glob:'wip:*') | description(glob:'private:*') | description(glob:'WIP:*') | description(glob:'PRIVATE:*') | conflicts() | (empty() ~ merges()) | description('substring-i:\"DO NOT MAIL\"')"
195 #"trunk()" = "main@rad"
196 #"immutable_heads()" = "tags()"
197 "immutable_heads()" = "present(trunk()) | tags() | ( untracked_remote_bookmarks() ~ untracked_remote_bookmarks(remote='rad') ~ untracked_remote_bookmarks(regex:'^patch(es)/',remote='rad'))"
198 #'default()' = 'coalesce(trunk(), root())::present(@) | ancestors(visible_heads(), 2)'
201 'bases' = 'present(main@rad) | present(master@origin) | present(main@origin)'
202 'downstream(x,y)' = '(x::y) & y'
203 'branches' = 'downstream(trunk(), bookmarks()) & mine()'
204 'branchesandheads' = 'branches | (heads(trunk()::) & mine())'
205 'curbranch' = 'latest(branches::@- & branches)'
206 'nextbranch' = 'roots(@:: & branchesandheads)'
208 'more' = 'log | ancestors(visible_heads(), 2)'
209 'unmerged()' = 'bookmarks() & ~(trunk():: | trunk())'
210 'recent()' = 'committer_date(after:"1 months ago")'
211 'recent(revset)' = 'revset & recent()'
214 # stack(x, n) is the set of mutable commits reachable from 'x', with 'n'
215 # parents. 'n' is often useful to customize the display and return set for
216 # certain operations. 'x' can be used to target the set of 'roots' to traverse,
217 # e.g. @ is the current stack.
218 'stack()' = 'ancestors(reachable(@, mutable()), 2)'
219 'stack(x)' = 'ancestors(reachable(x, mutable()), 2)'
220 'stack(x, n)' = 'ancestors(reachable(x, mutable()), n)'
222 # The current set of "open" works. It is defined as:
224 # - given the set of commits not in trunk, that are written by me,
225 # - calculate the given stack() for each of those commits
227 # n = 1, meaning that nothing from `trunk()` is included, so all resulting
228 # commits are mutable by definition.
229 'open()' = 'stack(trunk().. & mine(), 1)'
231 # the set of 'ready()' commits. defined as the set of open commits, but nothing
232 # that is blacklisted or any of their children.
234 # often used with gerrit, which you can use to submit whole stacks at once:
236 # - jj gerrit send -r 'ready()' --dry-run
237 'ready()' = 'open() ~ blacklist()::'
240 # Hide unnecessary bits to make the jj log more concise
241 #'format_short_change_id(id)' = 'id.shortest(4)'
242 #'format_short_commit_id(id)' = 'id.shortest(4)'
243 'format_timestamp(timestamp)' = 'timestamp.ago()'
245 #'format_short_signature(signature)' = 'signature.email()'
246 # Both name and email address
247 #'format_short_signature(signature)' = 'signature'
248 # Username part of the email address
249 #'format_short_signature(signature)' = 'signature.email().local()'
250 'format_short_signature(signature)' = 'signature.name()'
254 write-change-id-header = true
255 # Prevent pushing work in progress or anything explicitly labeled "private"
256 private-commits = "description(glob:'wip:*') | description(glob:'private:*')"
257 # Don't require --allow-new when pushing a new bookmark
258 push-new-bookmarks = true
259 fetch = ["origin", "rad"]
264 name = "Julien Moutinho"
265 email = "julm@sourcephile.fr"
269 default-command = "log"
270 diff-editor = ":builtin"
271 # From https://github.com/julienvincent/hunk.nvim
272 #diff-editor = ["nvim", "-c", "DiffEditor $left $right $output"]
274 [merge-tools.diffconflicts]
277 "-c", "let g:jj_diffconflicts_marker_length=$marker_length",
278 "-c", "JJDiffConflicts!", "$output", "$base", "$left", "$right",
280 merge-tool-edits-conflict-markers = true
282 # # via @dubi steinkek in the jj discord
283 # [merge-tools.gitpatch]
285 # edit-args = ["-c", '''
287 # rm -f "$right/JJ-INSTRUCTIONS"
288 # git -C "$left" init -q
289 # git -C "$left" add -A
290 # git -C "$left" commit -q -m baseline --allow-empty
291 # mv "$left/.git" "$right"
292 # git -C "$right" add --intent-to-add --ignore-removal . # tell git to include new files in interactive patch mode
293 # git -C "$right" add -p
294 # git -C "$right" diff-index --quiet --cached HEAD && { echo "No changes done, aborting split."; exit 1; }
295 # git -C "$right" commit -q -m split
296 # git -C "$right" reset -q --hard # undo changes in modified files, remove added files
299 # merge-args = ["-c", "echo gitpatch cannot be used as a diff tool"]
300 # diff-args = ["-c", "echo gitpatch cannot be used as a diff tool"]