Skip to content

fix(jj): scope the bundled filter to jj log - #5134

Merged
KuSh merged 3 commits into
rtk-ai:developfrom
LeviReisJs:fix/jj-filter-log-only
Nov 28, 2026
Merged

KuSh merged 3 commits into
rtk-ai:developfrom
LeviReisJs:fix/jj-filter-log-only

Conversation

@LeviReisJs

@LeviReisJs LeviReisJs commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The bundled jj filter matched every subcommand (^jj\b), but it is tuned for jj log: its 30-line cap left jj diff, jj show and jj file show with 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_command is now ^jj\s+log(\s.*)?$: only jj log keeps the filter. Bare jj runs whatever ui.default-command names, and a log-prefixed alias such as jj log-file can be file show, so both pass through untouched with every other subcommand (from review), and the hook no longer rewrites them to rtk 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.toml having 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 5 match the jj filter; jj, jj diff, jj show, jj file show a.py, jj logs, jj log-file match nothing, in both the registry and the match-only RegexSet. It failed on "jj diff" before the first commit and on "jj" before the review fix.

  • test_rewrite_toml_compound used jj diff as its compound example; it now uses jj log for the rewrite and also pins that jj diff && jq . becomes jj diff && rtk jq ..

  • cargo fmt --all -- --check

  • cargo clippy --all-targets -- -D warnings

  • cargo test --no-fail-fast on Windows 11: one more test passes than on a clean develop (8bb6096); the same 2 tests fail with and without this change (core::stream::...invalid_utf8 and find_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 against e5a0c46 with Jujutsu 0.47.1.

🤖 Generated with Claude Code

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 ychampion left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]>
@LeviReisJs

Copy link
Copy Markdown
Contributor Author

Thanks for running it against real Jujutsu, both cases are right. Fixed in 33c8074: the matcher is now ^jj\s+log(\s.*)?$, so it needs whitespace or end of input after log (jj log-file passes through) and bare jj is no longer filtered, since it runs whatever ui.default-command names. The test now pins jj and jj log-file as unmatched, and jj log, jj log -r @ and jj log<TAB>-n 5 as matched.

@TechWizard9999 TechWizard9999 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 KuSh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 log and jj evolog are 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, --stat and --summary still go through the 30-line cap (733, 146 and 109 lines → 32 here; the rest is recoverable with rtk 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, bare jj (default and ui.default-command = "log-file"), the log-file alias and an l = ["log", "-p"] alias are byte-identical to native on this head; jj file show a.py goes from 32 to 580 lines with the changed line back.
  • jj log keeps the filter with -r, -n, --no-graph, -T, a tab, an absolute path, an env prefix, timeout, 2>&1, --color=always and && …: same output as the merge-base.
  • jj refuses an alias named log ("Cannot define an alias that overrides the built-in command"), so jj log cannot be turned into a file read by configuration.
  • jj stays reserved for pipeline task names: the leading word is still extracted from the new pattern.
  • Exit codes match native: bad revset 1, jj logs 2, missing jj 127.
  • Gate on this head merged into develop: fmt, clippy, cargo test --all green.

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.

@KuSh
KuSh merged commit 8e79d00 into rtk-ai:develop Nov 28, 2026
16 checks passed
@rtk-release-bot rtk-release-bot Bot mentioned this pull request Nov 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants