From 7e54cd1e060333bb87aa1617ef340becbf30e911 Mon Sep 17 00:00:00 2001 From: gold-silver-copper <157451540+gold-silver-copper@users.noreply.github.com> Date: Sun, 25 Oct 2026 04:34:53 -0700 Subject: [PATCH 1/7] fix: pass git arguments through as argv Raw pass-through, commit -m and status build argv, so arguments reach git as typed. worktree exec --include/--exclude name whole repos. Implements [[tasks/harmony-2756]] --- src/commands/worktree/cli_types.rs | 6 +- src/commands/worktree/exec.rs | 44 ++++++----- src/commit.rs | 6 +- src/lib.rs | 114 ++++++++++++++++------------- src/status.rs | 2 +- 5 files changed, 96 insertions(+), 76 deletions(-) diff --git a/src/commands/worktree/cli_types.rs b/src/commands/worktree/cli_types.rs index 18e8878..e721f54 100644 --- a/src/commands/worktree/cli_types.rs +++ b/src/commands/worktree/cli_types.rs @@ -169,11 +169,13 @@ pub struct ExecArgs { /// Start from a specific commit-ish (ephemeral only) pub commit_ish: Option, - /// Only run in specified repos (comma-separated) + /// Only run in these repos (comma-separated): each value is a repo's .meta + /// name or its whole path from the worktree root (. for the root), never + /// part of one #[arg(long, value_delimiter = ',')] pub include: Vec, - /// Skip specified repos (comma-separated) + /// Skip these repos (comma-separated), named like --include #[arg(long, value_delimiter = ',')] pub exclude: Vec, diff --git a/src/commands/worktree/exec.rs b/src/commands/worktree/exec.rs index b6e9ea8..7b0c78b 100644 --- a/src/commands/worktree/exec.rs +++ b/src/commands/worktree/exec.rs @@ -2,6 +2,7 @@ use anyhow::Result; use colored::*; use std::path::Path; +use meta_cli::repo_filter; use meta_cli::worktree::{discover_worktree_repos, WorktreeRepoInfo}; use meta_git_lib::worktree::helpers::*; @@ -9,6 +10,7 @@ use super::cli_types::{CreateArgs, DestroyArgs, ExecArgs}; use crate::git_env; /// Runs in each of `repos`, naming them by their path from `wt_dir`. +/// `--include`/`--exclude` values name repos by `.meta` name or that path. fn build_loop_config( wt_dir: &Path, repos: &[WorktreeRepoInfo], @@ -17,20 +19,26 @@ fn build_loop_config( parallel: bool, verbose: bool, json: bool, -) -> loop_lib::LoopConfig { - loop_lib::LoopConfig { - directories: repos.iter().map(|r| r.path.display().to_string()).collect(), +) -> Result { + let directories: Vec = repos.iter().map(|r| r.path.display().to_string()).collect(); + let names = if include_filters.is_empty() && exclude_filters.is_empty() { + vec![] + } else { + find_meta_dir() + .map(|meta_dir| repo_filter::repo_names(&meta_dir)) + .unwrap_or_default() + }; + let resolve = |flag, values: Vec| -> Result>> { + if values.is_empty() { + return Ok(None); + } + repo_filter::resolve(flag, &values, &directories, wt_dir, &names).map(Some) + }; + Ok(loop_lib::LoopConfig { + include_filters: resolve("--include", include_filters)?, + exclude_filters: resolve("--exclude", exclude_filters)?, + directories, ignore: vec![], - include_filters: if include_filters.is_empty() { - None - } else { - Some(include_filters) - }, - exclude_filters: if exclude_filters.is_empty() { - None - } else { - Some(exclude_filters) - }, verbose, silent: false, parallel, @@ -41,7 +49,7 @@ fn build_loop_config( env: Some(git_env::git_env()), max_parallel: None, root_dir: Some(wt_dir.to_path_buf()), - } + }) } /// RAII guard that removes an ephemeral worktree on drop. @@ -84,7 +92,6 @@ pub(crate) fn handle_exec(args: ExecArgs, verbose: bool, json: bool) -> Result<( let name = &args.name; let repos = discover_and_validate_worktree(name)?; - let command_str = args.command.join(" "); let config = build_loop_config( &resolve_existing_worktree(name)?.wt_dir, &repos, @@ -93,9 +100,9 @@ pub(crate) fn handle_exec(args: ExecArgs, verbose: bool, json: bool) -> Result<( args.parallel, verbose, json, - ); + )?; - loop_lib::run(&config, &command_str)?; + loop_lib::run(&config, &args.command)?; Ok(()) } @@ -152,7 +159,6 @@ fn handle_ephemeral_exec(args: ExecArgs, verbose: bool, json: bool) -> Result<() // Run the command let repos = discover_worktree_repos(&wt_dir)?; - let command_str = cmd_parts.join(" "); let config = build_loop_config( &wt_dir, &repos, @@ -163,7 +169,7 @@ fn handle_ephemeral_exec(args: ExecArgs, verbose: bool, json: bool) -> Result<() json, ); - let exec_result = loop_lib::run(&config, &command_str); + let exec_result = config.and_then(|config| loop_lib::run(&config, &cmd_parts)); // Explicitly drop guard to trigger cleanup before propagating result drop(guard); diff --git a/src/commit.rs b/src/commit.rs index ce7d6b2..2cc4743 100644 --- a/src/commit.rs +++ b/src/commit.rs @@ -80,8 +80,6 @@ pub(crate) fn execute_git_commit( execute_editor_commit(&repos_with_changes)?; } else if let Some(msg) = message { // Apply same message to all repos - use ExecutionPlan for proper dry-run support - // Escape the message for shell (replace single quotes) - let escaped_msg = msg.replace('\'', "'\\''"); let commands: Vec = repos_with_changes .iter() .map(|(name, path, _files)| { @@ -93,7 +91,9 @@ pub(crate) fn execute_git_commit( }; PlannedCommand { dir, - cmd: format!("git commit -m '{escaped_msg}'"), + argv: ["git", "commit", "-m", msg.as_str()] + .map(str::to_string) + .to_vec(), env: None, } }) diff --git a/src/lib.rs b/src/lib.rs index 3ff4775..bda688c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -85,10 +85,10 @@ pub fn execute_command( } /// Check if a git command accesses remote repositories -fn is_remote_command(command: &str) -> bool { +fn is_remote_command(argv: &[String]) -> bool { let remote_commands = ["push", "pull", "fetch", "clone", "ls-remote"]; - let cmd_lower = command.to_lowercase(); - remote_commands.iter().any(|rc| cmd_lower.contains(rc)) + argv.get(1) + .is_some_and(|subcommand| remote_commands.contains(&subcommand.as_str())) } fn has_help_token(command: &str, args: &[String]) -> bool { @@ -132,7 +132,10 @@ fn build_passthrough_git_help( return None; } - let display_command = format!("git {}", git_args.join(" ")); + let git_argv: Vec = std::iter::once("git".to_string()) + .chain(git_args.iter().cloned()) + .collect(); + let display_command = loop_lib::display_command(&git_argv); let scope = match get_project_directories_with_fallback(projects, cwd) { Ok(dirs) => { if dirs.is_empty() { @@ -189,13 +192,13 @@ fn execute_raw_git_command( Err(e) => return CommandResult::Error(format!("Failed to get project directories: {e}")), }; - // Build the full git command string - // command is e.g. "git add ." and args contains any additional arguments - let full_cmd = if args.is_empty() { - command.to_string() - } else { - format!("{} {}", command, args.join(" ")) - }; + // The git argv: the command words (e.g. "git" or "git add") and the + // user's args exactly as given + let argv: Vec = command + .split_whitespace() + .map(str::to_string) + .chain(args.iter().cloned()) + .collect(); // Set git-specific environment variables (pager, colors, prompts) let git_env = Some(git_env::git_env()); @@ -204,14 +207,14 @@ fn execute_raw_git_command( .into_iter() .map(|dir| PlannedCommand { dir, - cmd: full_cmd.clone(), + argv: argv.clone(), env: git_env.clone(), }) .collect(); // For remote commands running in parallel, establish SSH ControlMaster // connections and inject GIT_SSH_COMMAND into each planned command. - if options.parallel && is_remote_command(command) { + if options.parallel && is_remote_command(&argv) { let urls = ssh::discover_ssh_urls(cwd); // HTTPS-only workspaces don't need SSH multiplexing @@ -341,6 +344,10 @@ Examples: #[cfg(test)] mod tests { use super::*; + + fn argv(line: &str) -> Vec { + line.split_whitespace().map(str::to_string).collect() + } use commit::parse_multi_commit_file; use helpers::get_project_directories; use meta_plugin_protocol::{ExecutionPlan, PlanResponse, PlannedCommand}; @@ -555,12 +562,12 @@ the only commit message commands: vec![ PlannedCommand { dir: "./repo1".to_string(), - cmd: "git status".to_string(), + argv: argv("git status"), env: None, }, PlannedCommand { dir: "./repo2".to_string(), - cmd: "git status".to_string(), + argv: argv("git status"), env: None, }, ], @@ -572,7 +579,7 @@ the only commit message let json = serde_json::to_string(&plan).unwrap(); assert!(json.contains("\"dir\":\"./repo1\"")); - assert!(json.contains("\"cmd\":\"git status\"")); + assert!(json.contains(r#""argv":["git","status"]"#)); assert!(json.contains("\"parallel\":false")); } @@ -582,7 +589,7 @@ the only commit message pre_commands: vec![], commands: vec![PlannedCommand { dir: ".".to_string(), - cmd: "ls".to_string(), + argv: argv("ls"), env: None, }], post_commands: vec![], @@ -602,13 +609,13 @@ the only commit message fn test_planned_command_serialization() { let cmd = PlannedCommand { dir: "/absolute/path".to_string(), - cmd: "git pull --rebase".to_string(), + argv: argv("git pull --rebase"), env: None, }; let json = serde_json::to_string(&cmd).unwrap(); assert!(json.contains("\"dir\":\"/absolute/path\"")); - assert!(json.contains("\"cmd\":\"git pull --rebase\"")); + assert!(json.contains(r#""argv":["git","pull","--rebase"]"#)); } #[test] @@ -618,7 +625,7 @@ the only commit message pre_commands: vec![], commands: vec![PlannedCommand { dir: "project".to_string(), - cmd: "make build".to_string(), + argv: argv("make build"), env: None, }], post_commands: vec![], @@ -632,7 +639,7 @@ the only commit message assert!(json.contains("\"plan\":")); assert!(json.contains("\"commands\":")); assert!(json.contains("\"dir\":\"project\"")); - assert!(json.contains("\"cmd\":\"make build\"")); + assert!(json.contains(r#""argv":["make","build"]"#)); assert!(json.contains("\"parallel\":true")); } @@ -645,12 +652,12 @@ the only commit message commands: vec![ PlannedCommand { dir: "a".to_string(), - cmd: "cmd1".to_string(), + argv: argv("cmd1"), env: None, }, PlannedCommand { dir: "b".to_string(), - cmd: "cmd2".to_string(), + argv: argv("cmd2"), env: None, }, ], @@ -671,7 +678,7 @@ the only commit message let commands = plan.get("commands").unwrap().as_array().unwrap(); assert_eq!(commands.len(), 2); assert_eq!(commands[0].get("dir").unwrap().as_str().unwrap(), "a"); - assert_eq!(commands[0].get("cmd").unwrap().as_str().unwrap(), "cmd1"); + assert_eq!(commands[0]["argv"], serde_json::json!(["cmd1"])); assert!(!plan.get("parallel").unwrap().as_bool().unwrap()); } @@ -694,26 +701,31 @@ the only commit message fn test_planned_command_with_special_chars() { let cmd = PlannedCommand { dir: "./path with spaces".to_string(), - cmd: "git commit -m \"feat: add feature\"".to_string(), + argv: vec![ + "git".to_string(), + "commit".to_string(), + "-m".to_string(), + "feat: \"add\" feature".to_string(), + ], env: None, }; let json = serde_json::to_string(&cmd).unwrap(); // JSON should properly escape the string assert!(json.contains("path with spaces")); - assert!(json.contains("\\\"feat: add feature\\\"")); + assert!(json.contains("\"feat: \\\"add\\\" feature\"")); } #[test] fn test_planned_command_git_clone() { let cmd = PlannedCommand { dir: "/home/user/workspace".to_string(), - cmd: "git clone git@github.com:org/repo.git my-repo".to_string(), + argv: argv("git clone git@github.com:org/repo.git my-repo"), env: None, }; let json = serde_json::to_string(&cmd).unwrap(); - assert!(json.contains("git clone")); + assert!(json.contains(r#""git","clone""#)); assert!(json.contains("git@github.com:org/repo.git")); } @@ -722,7 +734,7 @@ the only commit message let commands: Vec = (0..100) .map(|i| PlannedCommand { dir: format!("./repo_{i}"), - cmd: "git status".to_string(), + argv: argv("git status"), env: None, }) .collect(); @@ -814,7 +826,7 @@ the only commit message .into_iter() .map(|dir| PlannedCommand { dir, - cmd: "git status".to_string(), + argv: argv("git status"), env: None, }) .collect(); @@ -852,7 +864,7 @@ the only commit message .iter() .map(|(name, url)| PlannedCommand { dir: cwd.to_string(), - cmd: format!("git clone {url} {name}"), + argv: argv(&format!("git clone {url} {name}")), env: None, }) .collect(); @@ -871,7 +883,7 @@ the only commit message let json = serde_json::to_string(&response).unwrap(); // Verify clone commands are in the plan - assert!(json.contains("git clone")); + assert!(json.contains(r#""git","clone""#)); assert!(json.contains("repo1")); assert!(json.contains("repo2")); } @@ -880,44 +892,44 @@ the only commit message #[test] fn test_is_remote_command_push() { - assert!(super::is_remote_command("git push")); - assert!(super::is_remote_command("git push origin main")); + assert!(super::is_remote_command(&argv("git push"))); + assert!(super::is_remote_command(&argv("git push origin main"))); } #[test] fn test_is_remote_command_pull() { - assert!(super::is_remote_command("git pull")); - assert!(super::is_remote_command("git pull --rebase")); + assert!(super::is_remote_command(&argv("git pull"))); + assert!(super::is_remote_command(&argv("git pull --rebase"))); } #[test] fn test_is_remote_command_fetch() { - assert!(super::is_remote_command("git fetch")); - assert!(super::is_remote_command("git fetch --all")); + assert!(super::is_remote_command(&argv("git fetch"))); + assert!(super::is_remote_command(&argv("git fetch --all"))); } #[test] fn test_is_remote_command_clone() { - assert!(super::is_remote_command("git clone")); - assert!(super::is_remote_command( + assert!(super::is_remote_command(&argv("git clone"))); + assert!(super::is_remote_command(&argv( "git clone https://github.com/org/repo.git" - )); + ))); } #[test] fn test_is_remote_command_ls_remote() { - assert!(super::is_remote_command("git ls-remote")); + assert!(super::is_remote_command(&argv("git ls-remote"))); } #[test] fn test_is_remote_command_local_commands() { - assert!(!super::is_remote_command("git status")); - assert!(!super::is_remote_command("git add .")); - assert!(!super::is_remote_command("git commit -m \"msg\"")); - assert!(!super::is_remote_command("git log")); - assert!(!super::is_remote_command("git diff")); - assert!(!super::is_remote_command("git branch")); - assert!(!super::is_remote_command("git checkout main")); + assert!(!super::is_remote_command(&argv("git status"))); + assert!(!super::is_remote_command(&argv("git add ."))); + assert!(!super::is_remote_command(&argv("git commit -m \"msg\""))); + assert!(!super::is_remote_command(&argv("git log"))); + assert!(!super::is_remote_command(&argv("git diff"))); + assert!(!super::is_remote_command(&argv("git branch"))); + assert!(!super::is_remote_command(&argv("git checkout main"))); } #[test] @@ -926,7 +938,7 @@ the only commit message pre_commands: vec![], commands: vec![PlannedCommand { dir: ".".to_string(), - cmd: "git push".to_string(), + argv: argv("git push"), env: None, }], post_commands: vec![], @@ -951,7 +963,7 @@ the only commit message pre_commands: vec![], commands: vec![PlannedCommand { dir: ".".to_string(), - cmd: "git status".to_string(), + argv: argv("git status"), env: None, }], post_commands: vec![], diff --git a/src/status.rs b/src/status.rs index 1d817b7..9dafcff 100644 --- a/src/status.rs +++ b/src/status.rs @@ -19,7 +19,7 @@ pub(crate) fn execute_git_status( .into_iter() .map(|dir| PlannedCommand { dir, - cmd: "git status".to_string(), + argv: vec!["git".to_string(), "status".to_string()], env: git_env.clone(), }) .collect(); From a194ab54c76e701e5d62b39ebf61f373ae0f533d Mon Sep 17 00:00:00 2001 From: t Date: Sun, 25 Oct 2026 04:55:43 -0700 Subject: [PATCH 2/7] fix: worktree exec selects repos up front; snapshot restore refuses filters snapshot restore restores every repo in the snapshot, so it now refuses --include/--exclude instead of ignoring them. Implements [[tasks/harmony-2756]] --- src/commands/worktree/exec.rs | 30 +++++++++++++++--------------- src/lib.rs | 5 +++++ 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/commands/worktree/exec.rs b/src/commands/worktree/exec.rs index 7b0c78b..dcad918 100644 --- a/src/commands/worktree/exec.rs +++ b/src/commands/worktree/exec.rs @@ -9,8 +9,8 @@ use meta_git_lib::worktree::helpers::*; use super::cli_types::{CreateArgs, DestroyArgs, ExecArgs}; use crate::git_env; -/// Runs in each of `repos`, naming them by their path from `wt_dir`. -/// `--include`/`--exclude` values name repos by `.meta` name or that path. +/// Runs in each of `repos` that `--include`/`--exclude` select (a repo's +/// `.meta` name or its path from `wt_dir`), naming them by that path. fn build_loop_config( wt_dir: &Path, repos: &[WorktreeRepoInfo], @@ -21,22 +21,22 @@ fn build_loop_config( json: bool, ) -> Result { let directories: Vec = repos.iter().map(|r| r.path.display().to_string()).collect(); - let names = if include_filters.is_empty() && exclude_filters.is_empty() { - vec![] + let directories = if include_filters.is_empty() && exclude_filters.is_empty() { + directories } else { - find_meta_dir() - .map(|meta_dir| repo_filter::repo_names(&meta_dir)) - .unwrap_or_default() - }; - let resolve = |flag, values: Vec| -> Result>> { - if values.is_empty() { - return Ok(None); - } - repo_filter::resolve(flag, &values, &directories, wt_dir, &names).map(Some) + let tree = find_meta_dir() + .and_then(|meta_dir| meta_core::config::walk_meta_tree(&meta_dir, None).ok()) + .unwrap_or_default(); + let names = repo_filter::repo_names(&[], &tree); + repo_filter::select( + &include_filters, + &exclude_filters, + &directories, + wt_dir, + &names, + )? }; Ok(loop_lib::LoopConfig { - include_filters: resolve("--include", include_filters)?, - exclude_filters: resolve("--exclude", exclude_filters)?, directories, ignore: vec![], verbose, diff --git a/src/lib.rs b/src/lib.rs index bda688c..e3b2e21 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -70,6 +70,11 @@ pub fn execute_command( "git snapshot create" => snapshot::execute_snapshot_create(args, projects, cwd), "git snapshot list" => snapshot::execute_snapshot_list(cwd), "git snapshot show" => snapshot::execute_snapshot_show(args, cwd), + "git snapshot restore" if options.include_filters.is_some() || options.exclude_filters.is_some() => { + Err(anyhow::anyhow!( + "meta git snapshot restore restores every repo in the snapshot; it does not take --include/--exclude" + )) + } "git snapshot restore" => { snapshot::execute_snapshot_restore(args, projects, options.dry_run, cwd) } From 2845bfba7aa3b368a6cfb53cdbacef7222b32244 Mon Sep 17 00:00:00 2001 From: t Date: Sun, 25 Oct 2026 05:05:24 -0700 Subject: [PATCH 3/7] fix: git update refuses --include/--exclude It clones every missing repo the .meta files list, not the selected ones, so it refuses filters like snapshot restore does. Implements [[tasks/harmony-2756]] --- src/lib.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index e3b2e21..625d86c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -62,6 +62,14 @@ pub fn execute_command( } let result = match command { + // These act on repos they find themselves, not on the selected ones + "git snapshot restore" | "git update" + if options.include_filters.is_some() || options.exclude_filters.is_some() => + { + Err(anyhow::anyhow!( + "meta {command} works on every repo in the workspace; it does not take --include/--exclude" + )) + } "git status" => status::execute_git_status(projects, options, cwd), "git clone" => clone::execute_git_clone(args, options, cwd), "git update" => update::execute_git_update(projects, options.dry_run, cwd), @@ -70,11 +78,6 @@ pub fn execute_command( "git snapshot create" => snapshot::execute_snapshot_create(args, projects, cwd), "git snapshot list" => snapshot::execute_snapshot_list(cwd), "git snapshot show" => snapshot::execute_snapshot_show(args, cwd), - "git snapshot restore" if options.include_filters.is_some() || options.exclude_filters.is_some() => { - Err(anyhow::anyhow!( - "meta git snapshot restore restores every repo in the snapshot; it does not take --include/--exclude" - )) - } "git snapshot restore" => { snapshot::execute_snapshot_restore(args, projects, options.dry_run, cwd) } From fd9a34e5b6604ae2e2b269f0f26da1c3eadb616f Mon Sep 17 00:00:00 2001 From: t Date: Sun, 25 Oct 2026 05:17:49 -0700 Subject: [PATCH 4/7] fix: --help and -h after -- are arguments, not a help request Implements [[tasks/harmony-2756]] --- src/lib.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 625d86c..a8c23a9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -99,10 +99,15 @@ fn is_remote_command(argv: &[String]) -> bool { .is_some_and(|subcommand| remote_commands.contains(&subcommand.as_str())) } +/// A `--help`/`-h` before `--`; after it, they are arguments for the command. fn has_help_token(command: &str, args: &[String]) -> bool { command .split_whitespace() - .chain(args.iter().map(String::as_str)) + .chain( + args.iter() + .map(String::as_str) + .take_while(|arg| *arg != "--"), + ) .any(|arg| arg == "--help" || arg == "-h") } From 259312d54304b7a0121bb51f74064e239711009b Mon Sep 17 00:00:00 2001 From: t Date: Sun, 25 Oct 2026 05:38:41 -0700 Subject: [PATCH 5/7] fix: worktree commands refuse --include/--exclude given before them They find their repos in the set and used to ignore the global filters. worktree exec selects by alias. Implements [[tasks/harmony-2756]] --- src/commands/worktree/cli_types.rs | 5 ++--- src/commands/worktree/exec.rs | 27 ++++++++++----------------- src/lib.rs | 6 ++++++ 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/commands/worktree/cli_types.rs b/src/commands/worktree/cli_types.rs index e721f54..b01a1ee 100644 --- a/src/commands/worktree/cli_types.rs +++ b/src/commands/worktree/cli_types.rs @@ -169,9 +169,8 @@ pub struct ExecArgs { /// Start from a specific commit-ish (ephemeral only) pub commit_ish: Option, - /// Only run in these repos (comma-separated): each value is a repo's .meta - /// name or its whole path from the worktree root (. for the root), never - /// part of one + /// Only run in these repos (comma-separated): each value is a repo's alias, + /// its whole path in the set (. for the root), never part of one #[arg(long, value_delimiter = ',')] pub include: Vec, diff --git a/src/commands/worktree/exec.rs b/src/commands/worktree/exec.rs index dcad918..0f7f9da 100644 --- a/src/commands/worktree/exec.rs +++ b/src/commands/worktree/exec.rs @@ -9,8 +9,8 @@ use meta_git_lib::worktree::helpers::*; use super::cli_types::{CreateArgs, DestroyArgs, ExecArgs}; use crate::git_env; -/// Runs in each of `repos` that `--include`/`--exclude` select (a repo's -/// `.meta` name or its path from `wt_dir`), naming them by that path. +/// Runs in each of `repos` that `--include`/`--exclude` select (by alias: +/// its path from `wt_dir`), naming them by that path. fn build_loop_config( wt_dir: &Path, repos: &[WorktreeRepoInfo], @@ -21,21 +21,14 @@ fn build_loop_config( json: bool, ) -> Result { let directories: Vec = repos.iter().map(|r| r.path.display().to_string()).collect(); - let directories = if include_filters.is_empty() && exclude_filters.is_empty() { - directories - } else { - let tree = find_meta_dir() - .and_then(|meta_dir| meta_core::config::walk_meta_tree(&meta_dir, None).ok()) - .unwrap_or_default(); - let names = repo_filter::repo_names(&[], &tree); - repo_filter::select( - &include_filters, - &exclude_filters, - &directories, - wt_dir, - &names, - )? - }; + // A member sits at its alias, so its path in the set is its name + let directories = repo_filter::select( + &include_filters, + &exclude_filters, + &directories, + wt_dir, + &[], + )?; Ok(loop_lib::LoopConfig { directories, ignore: vec![], diff --git a/src/lib.rs b/src/lib.rs index a8c23a9..8f411f7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -47,6 +47,12 @@ pub fn execute_command( // Worktree commands (meta worktree * and meta git worktree *) // Checked before --help intercept so worktree subcommands can handle their own --help via clap if command.starts_with("worktree") || command.starts_with("git worktree") { + // They find their repos in the set; worktree exec takes its own filters + if options.include_filters.is_some() || options.exclude_filters.is_some() { + return CommandResult::Error(format!( + "meta {command} does not take --include/--exclude before it; use `meta git worktree exec --include -- `" + )); + } return commands::worktree::execute_worktree_command(command, args, options, cwd); } From 4dfac0fd23ad7f16a50ea2a9c033a5bb60b68daa Mon Sep 17 00:00:00 2001 From: t Date: Sun, 25 Oct 2026 05:54:42 -0700 Subject: [PATCH 6/7] docs: pass-through help puts meta options first; refusal names where repos come from Implements [[tasks/harmony-2756]] --- src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 8f411f7..8972828 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -73,7 +73,7 @@ pub fn execute_command( if options.include_filters.is_some() || options.exclude_filters.is_some() => { Err(anyhow::anyhow!( - "meta {command} works on every repo in the workspace; it does not take --include/--exclude" + "meta {command} finds its repos itself (in the snapshot or the .meta files); it does not take --include/--exclude" )) } "git status" => status::execute_git_status(projects, options, cwd), @@ -175,15 +175,15 @@ fn build_passthrough_git_help( Some(format!( "meta git {subcommand} - Pass-through git command\n\n\ -Usage: meta git {subcommand} [GIT_ARGS...] [META_OPTIONS]\n\n\ +Usage: meta [META_OPTIONS] git {subcommand} [GIT_ARGS...]\n\n\ Runs `{display_command}` in each repo in the current meta workspace.\n\n\ {scope}\n\n\ Meta options:\n\ --dry-run Show the command that would run in each repo\n\ --recursive Include repos from nested meta workspaces\n\ --depth Limit recursive traversal depth\n\ - --include Only run in specified repos/directories\n\ - --exclude Skip specified repos/directories\n\ + --include Only these repos (.meta name or path from the root)\n\ + --exclude Skip these repos (.meta name or path from the root)\n\ --tag Filter by project tag(s), comma-separated\n\ --parallel Run repo commands concurrently\n\ --sequential Run repo commands one at a time\n\n\ From 1294406fdf6226bf49dee05f6ab7cfbfd887e6ea Mon Sep 17 00:00:00 2001 From: t Date: Sun, 25 Oct 2026 06:18:41 -0700 Subject: [PATCH 7/7] fix: git clone refuses --include/--exclude in the plugin too Implements [[tasks/harmony-2756]] --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 8972828..e44defa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -69,7 +69,7 @@ pub fn execute_command( let result = match command { // These act on repos they find themselves, not on the selected ones - "git snapshot restore" | "git update" + "git snapshot restore" | "git update" | "git clone" if options.include_filters.is_some() || options.exclude_filters.is_some() => { Err(anyhow::anyhow!(