Repository navigation
fix(jj): scope the bundled filter to jj log - #5134
Conversation
The jj filter matched every subcommand, but it is tuned for log output: its 30-line cap left jj diff, jj show and jj file show with only unchanged context and hid the change set. Match jj log and bare jj only. Refs rtk-ai#5132 Co-Authored-By: Claude Opus 5.5 <[email protected]>
ychampion
left a comment
There was a problem hiding this comment.
I built e5a0c46 and ran the manual check with Jujutsu 0.47.1 in a colocated Git repo. RTK 1.2.0 cut jj diff, jj diff --git, jj show, and jj file show a.py to 32 lines and lost a change near the end of the fixture. This PR returns byte-for-byte native output for all four. An explicit jj log still compacts a 75-line result to 32 lines.
Two valid Jujutsu configurations still lose file content on this head. With the config below, native jj log-file and bare jj each print all 580 lines. rtk jj log-file and rtk jj each print 32 lines and omit the line near the end. All commands exit successfully.
aliases.log-file = ["file", "show", "a.py"]
ui.default-command = "log-file"\b after log matches before the hyphen, and bare jj can run a user-selected command. Could the built-in matcher require whitespace or end of input after log, and leave bare jj alone? That would preserve the explicit jj log savings while keeping these file reads intact. Jujutsu default command configuration
Review on rtk-ai#5134: `\b` after log also matched `jj log-file`, which can be an alias for `jj file show`, and bare `jj` runs ui.default-command, which need not be log. Match `jj log` followed by whitespace or end of input. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks for running it against real Jujutsu, both cases are right. Fixed in 33c8074: the matcher is now |
TechWizard9999
left a comment
There was a problem hiding this comment.
Thanks for this, and for the quick follow-up on log-file and bare jj. The new matcher looks right to me: the hook rewrite and the runtime lookup both go through it, so absolute paths, env prefixes and timeout wrappers still rewrite, and jj stays reserved for pipeline task names since the leading word is still extracted from the pattern. Both new tests fail if ^jj\b comes back.
One gap that's still open, probably better as a follow-up than part of this PR: jj log -p (also --patch, --git, --stat, --summary, --tool) still matches ^jj\s+log(\s.*)?$. That output is a diff, so it hits the same 30-line cap and blank-line strip described in #5132, e.g. rtk jj log -p -r @ on a large change still hides most of it. The regex crate has no lookahead, so excluding those flags in one pattern is awkward; a note in the TOML comment or a separate issue may be enough.
Minor: global flags before the subcommand (jj --no-pager log, jj -R ../repo log) are no longer filtered. That's the safe direction, just less savings.
cc @KuSh
The jj filter's test checked only flag arguments after `log` and a single space before it, so narrowing the matcher to `^jj log` or to flags only went unnoticed. Add a positional argument (`jj log a.py`), a tab and a double space between `jj` and `log`, and check the hook's match set for every row as the negative rows already do. Both case lists are sorted. Co-Authored-By: Claude Opus 5.5 <[email protected]>
KuSh
left a comment
There was a problem hiding this comment.
Round 1 of 3 — APPROVED, follow-ups filed
Claim: the bundled jj filter applies to jj log only; bare jj, every other subcommand and log-prefixed aliases run unfiltered, and the hook no longer rewrites them.
Scope: accept (round 1, frozen); maintainer PRs: overlaps #4341, whose test_builtin_match_command_words_end_at_ifs rejects \s in built-in match_command; this PR lands first, and I will rebase #4341 onto it with ^jj[ \t\n]+log(?:[ \t\n]|$) (all three tests pass on that merge). #5100, #5041, #5022, #4458: merge clean, no overlap.
Ran: Jujutsu 0.47.1 (Docker, LC_ALL=C), colocated repo with 35 commits and a 580-line file changed near its end; 38 command forms × merge-base 8bb6096 / head 33c8074, each through rtk rewrite then the returned command, plus rtk jj … directly; exit codes compared with native on every row. Invariants: under the hook (every row, and the rtk recall hint), over-cap + accounting (30 shown + 43 hidden = 73 raw), non-default targets (-r <first change>, -r 'all()', a path argument), every decision. Savings on jj log -r 'all()' 56% (2688 → 1181 bytes), --no-graph 55%, vs the 20% floor (CONTRIBUTING.md).
Pins: 6 decisions, 9 mutations, 0 survive at 57d5285 (2 survived at 33c8074: flags-only after log, a literal space before it; closed by the fixup).
Matrix: executed this round; pin check: executed this round
CI @57d5285: all green (16 checks)
Blocks merge (0)
None.
Optional — will not hold merge
jj op logandjj evologare log-shaped and no longer filtered, like the global-flag case the description names (jj --no-pager log,jj -R ../repo log). Both pass through in full, so nothing is lost; adding them back can be a follow-up.
Filed as follow-ups
- #5132 —
jj log -p,--git,--statand--summarystill go through the 30-line cap (733, 146 and 109 lines → 32 here; the rest is recoverable withrtk recall). Pre-existing and unchanged by this PR, raised by @TechWizard9999; comment added to #5132, which this PR leaves open.
Checked and correct — no need to re-verify
jj diff,jj diff --git,jj show,jj file show a.py,jj st,jj evolog,jj op log, barejj(default andui.default-command = "log-file"), thelog-filealias and anl = ["log", "-p"]alias are byte-identical to native on this head;jj file show a.pygoes from 32 to 580 lines with the changed line back.jj logkeeps the filter with-r,-n,--no-graph,-T, a tab, an absolute path, an env prefix,timeout,2>&1,--color=alwaysand&& …: same output as the merge-base.- jj refuses an alias named
log("Cannot define an alias that overrides the built-in command"), sojj logcannot be turned into a file read by configuration. jjstays reserved for pipeline task names: the leading word is still extracted from the new pattern.- Exit codes match native: bad revset 1,
jj logs2, missingjj127. - Gate on this head merged into develop: fmt, clippy,
cargo test --allgreen.
Your questions
None addressed to the maintainers; the jj log -p point is under follow-ups.
Next
Fixup 57d5285 pushed, code-reviewed: the test now also matches jj log a.py, jj<TAB>log and jj log, checks the hook's match set for every matched row, and both lists are sorted — approving.
Rounds: 1/3. Threads: 0 open, 0 resolved this round.
Summary
The bundled
jjfilter matched every subcommand (^jj\b), but it is tuned forjj log: its 30-line cap leftjj diff,jj showandjj file showwith only the unchanged context at the top and hid the actual change set (the report has a 526-line diff cut to 32 lines).match_commandis now^jj\s+log(\s.*)?$: onlyjj logkeeps the filter. Barejjruns whateverui.default-commandnames, and alog-prefixed alias such asjj log-filecan befile show, so both pass through untouched with every other subcommand (from review), and the hook no longer rewrites them tortk jj ....Known limit: a global flag before the subcommand (
jj -R repo log) no longer matches, so that case passes through in full rather than being compacted.This is the first half of #5132. The second half, user
filters.tomlhaving no effect, reproduced as working by design (trust gate on the global file too); details in the issue.Part of #5132
Test plan
New
core::toml_filter::tests::jj_filter_covers_log_only:jj log,jj log -r @,jj log<TAB>-n 5match thejjfilter;jj,jj diff,jj show,jj file show a.py,jj logs,jj log-filematch nothing, in both the registry and the match-onlyRegexSet. It failed on"jj diff"before the first commit and on"jj"before the review fix.test_rewrite_toml_compoundusedjj diffas its compound example; it now usesjj logfor the rewrite and also pins thatjj diff && jq .becomesjj diff && rtk jq ..cargo fmt --all -- --checkcargo clippy --all-targets -- -D warningscargo test --no-fail-faston Windows 11: one more test passes than on a cleandevelop(8bb6096); the same 2 tests fail with and without this change (core::stream::...invalid_utf8andfind_cmd::run_from_args_propagates_find_exit_status), neither related to jj or filters.Manual
rtk jj ...: not run here (no jj installed); @ychampion's review ran it againste5a0c46with Jujutsu 0.47.1.🤖 Generated with Claude Code