fix(dispatch): detect jj show's positional revset argument
The 0.3.0 help-driven dispatch only scanned a leaf's `Options:` block for a revset flag. `jj show` takes its revision as a positional `[REVSET]` argument, not an option, so it looked like it accepted no revset — and bare `jjf` (which defaults to `show`) errored with "takes no revset flag" instead of opening the picker. - Read the `Arguments:` block too: a positional `[REVSET]`/`[REVSETS]` that exposes `-r` as an alias is recognized, and jjf injects `-r <picked>` for it. - A bare positional in the passthrough now counts as the user having named the revision, so `jjf show @-` bypasses the picker like an explicit `-r` would. Option values are stepped over (parsing every `Options:` section, including globals) so they aren't mistaken for the positional. - The picker-bypass check also accepts the inline `--revision=<rev>` / `--to=<rev>` form, not just space-separated flags. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2 files changed
+321
-28
No files matched your search
+5
-13
@@ -68,10 +68,11 @@ fn run_init(mut args: impl Iterator<Item = String>) -> Result<u8> {
|
||||
fn run_pick(args: &[String], emit: bool) -> Result<u8> {
|
||||
let target = jj::resolve_target(args)?;
|
||||
|
||||
// Case 1: user already supplied a revset flag — bypass the picker entirely
|
||||
// and run their command verbatim. Avoids double-`-r` and respects what
|
||||
// they explicitly asked for.
|
||||
if has_user_revset_flag(&target.passthrough) {
|
||||
// Case 1: user already pinned the revision — a revset flag, or a bare
|
||||
// positional for a positional-revset leaf like `jj show`. Bypass the
|
||||
// picker entirely and run their command verbatim. Avoids double-`-r` and
|
||||
// respects what they explicitly asked for.
|
||||
if target.user_supplied_revset {
|
||||
if emit {
|
||||
let cmd = jj::command_line(&target, &[]);
|
||||
println!("{cmd}");
|
||||
@@ -132,15 +133,6 @@ fn run_pick(args: &[String], emit: bool) -> Result<u8> {
|
||||
}
|
||||
}
|
||||
|
||||
fn has_user_revset_flag(passthrough: &[String]) -> bool {
|
||||
passthrough.iter().any(|a| {
|
||||
matches!(
|
||||
a.as_str(),
|
||||
"-r" | "--revision" | "--revisions" | "-t" | "--to"
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
fn redirect_stdout_to_tty() -> Result<libc::c_int> {
|
||||
use std::os::fd::AsRawFd;
|
||||
|
||||
Reference in new issue
Block a user