]> Git — Sourcephile - julm/julm-nix.git/blob - home-manager/profiles/jujutsu/jj/config.toml
+use/op(jj): enable watchman
[julm/julm-nix.git] / home-manager / profiles / jujutsu / jj / config.toml
1 [fsmonitor]
2 backend = "watchman"
3 fsmonitor.watchman.register-snapshot-trigger = true
4
5 [snapshot]
6 max-new-file-size = "2MiB"
7 auto-update-stale = true
8
9 [aliases]
10 a = ["absorb"]
11 dlog = ["log", "-r"]
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.
17 tug = [
18 "bookmark",
19 "move",
20 "--from",
21 "closest_bookmark(@)",
22 "--to",
23 "closest_pushable(@)",
24 ]
25 bl = ["bookmark", "list"]
26 blr = ["bookmark", "list", "--revisions", "recent()"]
27 c = ["commit"]
28 ci = ["commit", "--interactive"] # commit interactive
29 m = ["describe"]
30 mm = ["describe", "--message"]
31 d = ["diff", "--stat", "--revisions"]
32 dd = ["diff", "--revisions"]
33 dp = ["describe", "@-"] # describe previous
34 e = ["edit"]
35 para = [ "parallelize", "closest_tip()..@-" ]
36 pull = ["git", "fetch"]
37 push = ["git", "push"]
38 gf = ["git", "fetch"] # git fetchq
39 gi = ["git", "init", "--colocate"]
40 gp = ["git", "push"] # git push
41 i = ["git", "init", "--colocate"]
42 nb = ["bookmark", "create", "-r @-"] # new bookmark (for creating bookmark to push)
43 nc = ["new", "-B", "@", "--no-edit"] # new change before
44 r = ["rebase"]
45 rm = ["rebase", "-d", "main"] # "re-main"
46 s = ["show", "--stat"]
47 ss = ["show"]
48 sq = ["squash"]
49 sqi = ["squash", "--interactive"]
50 si = ["squash", "--interactive"]
51 sp = ["show", "@-"]
52 up = ["util", "exec", "--", "sh", "-c", """
53 if [ $# == 0 ]; then
54 jj bookmark move --from "closest_bookmark(@)" --to "closest_pushable(@)"
55 else
56 jj bookmark move --to "closest_pushable(@)" "$@"
57 fi
58 """, ""]
59 upp = ["util", "exec", "--", "sh", "-c", "jj up && jj git push", ""]
60
61 track-github-PR = ["util", "exec", "--", 'sh', '-euxc', '''
62 PR=$1
63 gh pr view --json headRepository,headRefName,headRepositoryOwner $PR --jq '"
64 set_remote() {
65 jj 2>/dev/null git remote add \"$1\" \"$2\" ||
66 jj git remote set-url \"$1\" \"$2\"
67 }
68 set_remote \(.headRepositoryOwner.login) git@github.com:\(.headRepositoryOwner.login)/\(.headRepository.name)
69 jj git fetch --remote \(.headRepositoryOwner.login) --branch \(.headRefName)
70 jj bookmark track \(.headRefName)@\(.headRepositoryOwner.login)
71 origin=$(gh repo view --json owner,name --jq .owner.login)
72 set_remote \"$origin\" \"$(gh repo view --json sshUrl --jq .sshUrl)\"
73 git fetch --force --update-head-ok \"$origin\" \"refs/pull/'"$PR"'/head:refs/remotes/$origin/pull/'"$PR"'\"
74 "' |
75 sh -euxs
76 ''', "jj-track-github-PR"]
77
78 untrack-github-PR = ["util", "exec", "--", 'sh', '-euxc', '''
79 PR=$1
80 gh pr view --json headRepository,headRefName,headRepositoryOwner $PR --jq '"
81 jj bookmark forget \(.headRefName) || true
82 origin=$(gh repo view --json owner,name --jq .owner.login)
83 git for-each-ref --format \"delete %(refname)\" \\
84 \"refs/remotes/\(.headRepositoryOwner.login)/\(.headRefName)\" \\
85 \"refs/remotes/$origin/pull/'"$PR"'\" |
86 tee /dev/stderr |
87 git update-ref --stdin
88 "' |
89 sh -euxs
90 ''', "jj-untrack-github-PR"]
91
92 # Get all open stacks of work.
93 open = ["log", "-r", "open()"]
94
95 # Better name, IMO.
96 credit = ["file", "annotate"]
97
98 # Retrunk a series. Typically used as `jj retrunk -s ...`, and notably can be
99 # used with open:
100 # - jj retrunk -s 'all:roots(open())'
101 retrunk = ["rebase", "-d", "trunk()"]
102
103 # Retrunk the current stack of work.
104 reheat = ["rebase", "-d", "trunk()", "-s", "all:roots(trunk()..stack(@))"]
105
106 # Take content from any change, and move it into @.
107 # - jj consume xyz path/to/file`
108 consume = ["squash", "--into", "@", "--from"]
109
110 # Eject content from @ into any other change.
111 # - jj eject xyz --interactive
112 eject = ["squash", "--from", "@", "--into"]
113
114
115 # All operations
116 o = ["op", "log"]
117 # All operations, with more whitespace
118 oo = ["op", "log", "-T", "builtin_op_log_comfortable"]
119
120 abandon-empties = ["abandon", "-r", "description(exact:'') ~ root()"]
121
122 # Move $commit just after the bookmark, and then move $bookmark on top of it.
123 #
124 # "$bookmark+" works, because after rebase -A, the only child of $bookmark is $commit.
125 # I do not use $commit itself because it might point to a
126 # different commit after the rebase (e.g. @-).
127 #
128 # My workflow uses mega-merge: I write a commit or two,
129 # and then move them to relevant branches with jj to.
130 # As a bonus, bookmarks are kept up-to-date for easy pushing.
131 # https://github.com/jj-vcs/jj/discussions/5568#discussioncomment-14289564
132 to = ['util', 'exec', '--', 'sh', '-c', '''
133 set -eux
134
135 bookmark=$1
136 commit=${2-}
137
138 # default to latest non-ephemeral commit
139 if [ -z "$commit" ]; then
140 commit=$(jj log --no-graph -T change_id -r '@ ~ ephemeral')
141 if [ -n "$commit" ]; then
142 # Moving current commit, create a new one to preserve
143 # current position in the commit DAG
144 jj new
145 else
146 commit=@-
147 fi
148 fi
149
150 jj rebase -r "$commit" -A "$bookmark"
151 jj bookmark move -f "$bookmark" -t "$bookmark+"
152 ''', 'jj-to']
153
154 [revsets]
155 # Focus current commit, trunk(), on local work and remote work by removing ancestors of trunk()
156 log = "@ | trunk() | ancestors_and_children(bookmarks() | tracked_remote_bookmarks()) ~ ..trunk()"
157
158 [revset-aliases]
159 "active(rev)" = "(ancestors(rev) | descendants(rev)) ~ immutable()"
160 "ancestors_and_children(x)" = "..x | x::"
161
162 # Remote commits not merged in trunk()
163 "review(x)" = "ancestors_and_children(remote_bookmarks(x)) ~ ..trunk()"
164
165 # Authored or committed by specified user
166 'user(x)' = 'author(x) | committer(x)'
167
168 'closest_tip()' = 'heads(::@ & remote_bookmarks())'
169
170 # Those who would be abandoned if you check out something else
171 ephemeral = 'description(exact:"") & empty()'
172
173 # show everything in the current set of branches off of trunk():
174 branch = '(coalesce(trunk(),root())..@)- | (coalesce(trunk(),root())..@)::'
175
176 # radicle
177 'closest_bookmark(to)' = 'heads(::to & bookmarks())'
178 'closest_pushable(to)' = 'heads(::to & mutable() & ~description(exact:"") & (~empty() | merges()))'
179
180 "desc(x)" = "description(x)"
181 "pending()" = ".. ~ ::tags() ~ ::remote_bookmarks() ~ @ ~ private()"
182 "private()" = "description(glob:'wip:*') | description(glob:'private:*') | description(glob:'WIP:*') | description(glob:'PRIVATE:*') | conflicts() | (empty() ~ merges()) | description('substring-i:\"DO NOT MAIL\"')"
183 #"trunk()" = "main@rad"
184 #"immutable_heads()" = "tags()"
185 "immutable_heads()" = "present(trunk()) | tags() | ( untracked_remote_bookmarks() ~ untracked_remote_bookmarks(remote='rad') ~ untracked_remote_bookmarks(regex:'^patch(es)/',remote='rad'))"
186 #'default()' = 'coalesce(trunk(), root())::present(@) | ancestors(visible_heads(), 2)'
187
188 # dev
189 'bases' = 'present(main@rad) | present(master@origin) | present(main@origin)'
190 'downstream(x,y)' = '(x::y) & y'
191 'branches' = 'downstream(trunk(), bookmarks()) & mine()'
192 'branchesandheads' = 'branches | (heads(trunk()::) & mine())'
193 'curbranch' = 'latest(branches::@- & branches)'
194 'nextbranch' = 'roots(@:: & branchesandheads)'
195
196 'more' = 'log | ancestors(visible_heads(), 2)'
197 'unmerged()' = 'bookmarks() & ~(trunk():: | trunk())'
198 'recent()' = 'committer_date(after:"1 months ago")'
199 'recent(revset)' = 'revset & recent()'
200
201
202 # stack(x, n) is the set of mutable commits reachable from 'x', with 'n'
203 # parents. 'n' is often useful to customize the display and return set for
204 # certain operations. 'x' can be used to target the set of 'roots' to traverse,
205 # e.g. @ is the current stack.
206 'stack()' = 'ancestors(reachable(@, mutable()), 2)'
207 'stack(x)' = 'ancestors(reachable(x, mutable()), 2)'
208 'stack(x, n)' = 'ancestors(reachable(x, mutable()), n)'
209
210 # The current set of "open" works. It is defined as:
211 #
212 # - given the set of commits not in trunk, that are written by me,
213 # - calculate the given stack() for each of those commits
214 #
215 # n = 1, meaning that nothing from `trunk()` is included, so all resulting
216 # commits are mutable by definition.
217 'open()' = 'stack(trunk().. & mine(), 1)'
218
219 # the set of 'ready()' commits. defined as the set of open commits, but nothing
220 # that is blacklisted or any of their children.
221 #
222 # often used with gerrit, which you can use to submit whole stacks at once:
223 #
224 # - jj gerrit send -r 'ready()' --dry-run
225 'ready()' = 'open() ~ blacklist()::'
226
227 [template-aliases]
228 # Hide unnecessary bits to make the jj log more concise
229 #'format_short_change_id(id)' = 'id.shortest(4)'
230 #'format_short_commit_id(id)' = 'id.shortest(4)'
231 'format_timestamp(timestamp)' = 'timestamp.ago()'
232
233 #'format_short_signature(signature)' = 'signature.email()'
234 # Both name and email address
235 #'format_short_signature(signature)' = 'signature'
236 # Username part of the email address
237 #'format_short_signature(signature)' = 'signature.email().local()'
238 'format_short_signature(signature)' = 'signature.name()'
239
240
241 [git]
242 write-change-id-header = true
243 # Prevent pushing work in progress or anything explicitly labeled "private"
244 private-commits = "description(glob:'wip:*') | description(glob:'private:*')"
245 # Don't require --allow-new when pushing a new bookmark
246 push-new-bookmarks = true
247 fetch = ["origin", "rad"]
248 push = "origin"
249
250
251 [user]
252 name = "Julien Moutinho"
253 email = "julm@sourcephile.fr"
254
255 [ui]
256 paginate = "auto"
257 default-command = "log"
258 diff-editor = ":builtin"
259 # From https://github.com/julienvincent/hunk.nvim
260 #diff-editor = ["nvim", "-c", "DiffEditor $left $right $output"]
261
262 [merge-tools.diffconflicts]
263 program = "nvim"
264 merge-args = [
265 "-c", "let g:jj_diffconflicts_marker_length=$marker_length",
266 "-c", "JJDiffConflicts!", "$output", "$base", "$left", "$right",
267 ]
268 merge-tool-edits-conflict-markers = true
269
270 # # via @dubi steinkek in the jj discord
271 # [merge-tools.gitpatch]
272 # program = "sh"
273 # edit-args = ["-c", '''
274 # set -eu
275 # rm -f "$right/JJ-INSTRUCTIONS"
276 # git -C "$left" init -q
277 # git -C "$left" add -A
278 # git -C "$left" commit -q -m baseline --allow-empty
279 # mv "$left/.git" "$right"
280 # git -C "$right" add --intent-to-add --ignore-removal . # tell git to include new files in interactive patch mode
281 # git -C "$right" add -p
282 # git -C "$right" diff-index --quiet --cached HEAD && { echo "No changes done, aborting split."; exit 1; }
283 # git -C "$right" commit -q -m split
284 # git -C "$right" reset -q --hard # undo changes in modified files, remove added files
285 # ''',
286 # ]
287 # merge-args = ["-c", "echo gitpatch cannot be used as a diff tool"]
288 # diff-args = ["-c", "echo gitpatch cannot be used as a diff tool"]