jj templates add try(expr, fallback...)
Introduced 2026-08-06 · score 0.95
HOW TO USE IT
When a template expression can fail at runtime, wrap it in `try(...)` to return the first successful expression and suppress earlier runtime errors; parsing errors still pass through.
jj log -T 'try(expr, fallback)'WHY THIS HELPS
When a template expression may fail at runtime, provide a fallback value.
REQUIREMENTS AND LIMITATIONS
- Version: v0.44.0
- expr (required): Template expression evaluated first.
- fallback...: Zero or more expressions evaluated in order; returns the first successful result. Earlier runtime errors are suppressed; parsing errors, including type errors, pass through.
FIRST-PARTY EVIDENCE
- https://github.com/jj-vcs/jj/releases/tag/v0.44.0
- https://github.com/jj-vcs/jj/blob/v0.44.0/docs/templates.md
Check the installed version and the source before using it. Entry JSON