4 l = ["log", "-r", "(trunk()..@):: | (trunk()..@)-"]
5 #l = ["log", "-r", "more()"]
6 fresh = ["new", "trunk()"]
7 # Figures out the closest bookmark
8 # and pulls it up to the latest change that can be pushed.
13 "closest_bookmark(@)",
15 "closest_pushable(@)",
17 bl = ["bookmark", "list"]
18 blr = ["bookmark", "list", "--revisions", "recent()"]
20 ci = ["commit", "--interactive"] # commit interactive
22 mm = ["describe", "--message"]
23 d = ["diff", "--stat", "--revisions"]
24 dd = ["diff", "--revisions"]
25 dp = ["describe", "@-"] # describe previous
27 para = [ "parallelize", "closest_tip()..@-" ]
28 pull = ["git", "fetch"]
29 push = ["git", "push"]
30 gf = ["git", "fetch"] # git fetchq
31 gi = ["git", "init", "--colocate"]
32 gp = ["git", "push"] # git push
33 i = ["git", "init", "--colocate"]
34 nb = ["bookmark", "create", "-r @-"] # new bookmark (for creating bookmark to push)
35 nc = ["new", "-B", "@", "--no-edit"] # new change before
37 rm = ["rebase", "-d", "main"] # "re-main"
38 s = ["show", "--stat"]
41 sqi = ["squash", "--interactive"]
42 si = ["squash", "--interactive"]
44 up = ["util", "exec", "--", "sh", "-c", """
46 jj bookmark move --from "closest_bookmark(@)" --to "closest_pushable(@)"
48 jj bookmark move --to "closest_pushable(@)" "$@"
51 upp = ["util", "exec", "--", "sh", "-c", "jj up && jj git push", ""]
53 track-github-PR = ["util", "exec", "--", 'sh', '-euxc', '''
55 gh pr view --json headRepository,headRefName,headRepositoryOwner $PR --jq '"
57 jj 2>/dev/null git remote add \"$1\" \"$2\" ||
58 jj git remote set-url \"$1\" \"$2\"
60 set_remote \(.headRepositoryOwner.login) git@github.com:\(.headRepositoryOwner.login)/\(.headRepository.name)
61 jj git fetch --remote \(.headRepositoryOwner.login) --branch \(.headRefName)
62 jj bookmark track \(.headRefName)@\(.headRepositoryOwner.login)
63 origin=$(gh repo view --json owner,name --jq .owner.login)
64 set_remote \"$origin\" \"$(gh repo view --json sshUrl --jq .sshUrl)\"
65 git fetch --force --update-head-ok \"$origin\" \"refs/pull/'"$PR"'/head:refs/remotes/$origin/pull/'"$PR"'\"
68 ''', "jj-track-github-PR"]
70 untrack-github-PR = ["util", "exec", "--", 'sh', '-euxc', '''
72 gh pr view --json headRepository,headRefName,headRepositoryOwner $PR --jq '"
73 jj bookmark forget \(.headRefName) || true
74 origin=$(gh repo view --json owner,name --jq .owner.login)
75 git for-each-ref --format \"delete %(refname)\" \\
76 \"refs/remotes/\(.headRepositoryOwner.login)/\(.headRefName)\" \\
77 \"refs/remotes/$origin/pull/'"$PR"'\" |
79 git update-ref --stdin
82 ''', "jj-untrack-github-PR"]
84 # Get all open stacks of work.
85 open = ["log", "-r", "open()"]
88 credit = ["file", "annotate"]
90 # Retrunk a series. Typically used as `jj retrunk -s ...`, and notably can be
92 # - jj retrunk -s 'all:roots(open())'
93 retrunk = ["rebase", "-d", "trunk()"]
95 # Retrunk the current stack of work.
96 reheat = ["rebase", "-d", "trunk()", "-s", "all:roots(trunk()..stack(@))"]
98 # Take content from any change, and move it into @.
99 # - jj consume xyz path/to/file`
100 consume = ["squash", "--into", "@", "--from"]
102 # Eject content from @ into any other change.
103 # - jj eject xyz --interactive
104 eject = ["squash", "--from", "@", "--into"]
109 # All operations, with more whitespace
110 oo = ["op", "log", "-T", "builtin_op_log_comfortable"]
112 abandon-empties = ["abandon", "-r", "description(exact:'') ~ root()"]
114 # Move $commit just after the bookmark, and then move $bookmark on top of it.
116 # "$bookmark+" works, because after rebase -A, the only child of $bookmark is $commit.
117 # I do not use $commit itself because it might point to a
118 # different commit after the rebase (e.g. @-).
120 # My workflow uses mega-merge: I write a commit or two,
121 # and then move them to relevant branches with jj to.
122 # As a bonus, bookmarks are kept up-to-date for easy pushing.
123 # https://github.com/jj-vcs/jj/discussions/5568#discussioncomment-14289564
124 to = ['util', 'exec', '--', 'sh', '-c', '''
130 # default to latest non-ephemeral commit
131 if [ -z "$commit" ]; then
132 commit=$(jj log --no-graph -T change_id -r '@ ~ ephemeral')
133 if [ -n "$commit" ]; then
134 # Moving current commit, create a new one to preserve
135 # current position in the commit DAG
142 jj rebase -r "$commit" -A "$bookmark"
143 jj bookmark move -f "$bookmark" -t "$bookmark+"
147 # Focus current commit, trunk(), on local work and remote work by removing ancestors of trunk()
148 log = "@ | trunk() | ancestors_and_children(bookmarks() | tracked_remote_bookmarks()) ~ ..trunk()"
151 "active(rev)" = "(ancestors(rev) | descendants(rev)) ~ immutable()"
152 "ancestors_and_children(x)" = "..x | x::"
154 # Remote commits not merged in trunk()
155 "review(x)" = "ancestors_and_children(remote_bookmarks(x)) ~ ..trunk()"
157 # Authored or committed by specified user
158 'user(x)' = 'author(x) | committer(x)'
160 'closest_tip()' = 'heads(::@ & remote_bookmarks())'
162 # Those who would be abandoned if you check out something else
163 ephemeral = 'description(exact:"") & empty()'
165 # show everything in the current set of branches off of trunk():
166 branch = '(coalesce(trunk(),root())..@)- | (coalesce(trunk(),root())..@)::'
169 'closest_bookmark(to)' = 'heads(::to & bookmarks())'
170 'closest_pushable(to)' = 'heads(::to & mutable() & ~description(exact:"") & (~empty() | merges()))'
172 "desc(x)" = "description(x)"
173 "pending()" = ".. ~ ::tags() ~ ::remote_bookmarks() ~ @ ~ private()"
174 "private()" = "description(glob:'wip:*') | description(glob:'private:*') | description(glob:'WIP:*') | description(glob:'PRIVATE:*') | conflicts() | (empty() ~ merges()) | description('substring-i:\"DO NOT MAIL\"')"
175 #"trunk()" = "main@rad"
176 #"immutable_heads()" = "tags()"
177 "immutable_heads()" = "present(trunk()) | tags() | ( untracked_remote_bookmarks() ~ untracked_remote_bookmarks(remote='rad') ~ untracked_remote_bookmarks(regex:'^patch(es)/',remote='rad'))"
178 #'default()' = 'coalesce(trunk(), root())::present(@) | ancestors(visible_heads(), 2)'
181 'bases' = 'present(main@rad) | present(master@origin) | present(main@origin)'
182 'downstream(x,y)' = '(x::y) & y'
183 'branches' = 'downstream(trunk(), bookmarks()) & mine()'
184 'branchesandheads' = 'branches | (heads(trunk()::) & mine())'
185 'curbranch' = 'latest(branches::@- & branches)'
186 'nextbranch' = 'roots(@:: & branchesandheads)'
188 'more' = 'log | ancestors(visible_heads(), 2)'
189 'unmerged()' = 'bookmarks() & ~(trunk():: | trunk())'
190 'recent()' = 'committer_date(after:"1 months ago")'
191 'recent(revset)' = 'revset & recent()'
194 # stack(x, n) is the set of mutable commits reachable from 'x', with 'n'
195 # parents. 'n' is often useful to customize the display and return set for
196 # certain operations. 'x' can be used to target the set of 'roots' to traverse,
197 # e.g. @ is the current stack.
198 'stack()' = 'ancestors(reachable(@, mutable()), 2)'
199 'stack(x)' = 'ancestors(reachable(x, mutable()), 2)'
200 'stack(x, n)' = 'ancestors(reachable(x, mutable()), n)'
202 # The current set of "open" works. It is defined as:
204 # - given the set of commits not in trunk, that are written by me,
205 # - calculate the given stack() for each of those commits
207 # n = 1, meaning that nothing from `trunk()` is included, so all resulting
208 # commits are mutable by definition.
209 'open()' = 'stack(trunk().. & mine(), 1)'
211 # the set of 'ready()' commits. defined as the set of open commits, but nothing
212 # that is blacklisted or any of their children.
214 # often used with gerrit, which you can use to submit whole stacks at once:
216 # - jj gerrit send -r 'ready()' --dry-run
217 'ready()' = 'open() ~ blacklist()::'
220 # Hide unnecessary bits to make the jj log more concise
221 #'format_short_change_id(id)' = 'id.shortest(4)'
222 #'format_short_commit_id(id)' = 'id.shortest(4)'
223 'format_timestamp(timestamp)' = 'timestamp.ago()'
225 #'format_short_signature(signature)' = 'signature.email()'
226 # Both name and email address
227 #'format_short_signature(signature)' = 'signature'
228 # Username part of the email address
229 #'format_short_signature(signature)' = 'signature.email().local()'
230 'format_short_signature(signature)' = 'signature.name()'
234 write-change-id-header = true
235 # Prevent pushing work in progress or anything explicitly labeled "private"
236 private-commits = "description(glob:'wip:*') | description(glob:'private:*')"
237 # Don't require --allow-new when pushing a new bookmark
238 push-new-bookmarks = true
239 fetch = ["origin", "rad"]
244 name = "Julien Moutinho"
245 email = "julm@sourcephile.fr"
249 default-command = "log"
250 diff-editor = ":builtin"
251 # From https://github.com/julienvincent/hunk.nvim
252 #diff-editor = ["nvim", "-c", "DiffEditor $left $right $output"]
254 [merge-tools.diffconflicts]
257 "-c", "let g:jj_diffconflicts_marker_length=$marker_length",
258 "-c", "JJDiffConflicts!", "$output", "$base", "$left", "$right",
260 merge-tool-edits-conflict-markers = true
262 # # via @dubi steinkek in the jj discord
263 # [merge-tools.gitpatch]
265 # edit-args = ["-c", '''
267 # rm -f "$right/JJ-INSTRUCTIONS"
268 # git -C "$left" init -q
269 # git -C "$left" add -A
270 # git -C "$left" commit -q -m baseline --allow-empty
271 # mv "$left/.git" "$right"
272 # git -C "$right" add --intent-to-add --ignore-removal . # tell git to include new files in interactive patch mode
273 # git -C "$right" add -p
274 # git -C "$right" diff-index --quiet --cached HEAD && { echo "No changes done, aborting split."; exit 1; }
275 # git -C "$right" commit -q -m split
276 # git -C "$right" reset -q --hard # undo changes in modified files, remove added files
279 # merge-args = ["-c", "echo gitpatch cannot be used as a diff tool"]
280 # diff-args = ["-c", "echo gitpatch cannot be used as a diff tool"]