From 368f0556267b32c5478b7fb68b8a30d42942ee6f Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 10 Apr 2026 19:47:52 +0000 Subject: fix: pass --git-dir as global git option in check_repo_empty --git-dir must precede the subcommand; passing it after for-each-ref caused git to ignore it and check the CWD instead, making every repo appear empty. --- src/cleanup_empty_repos.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/cleanup_empty_repos.rs b/src/cleanup_empty_repos.rs index f1d1c3e..8f5492d 100644 --- a/src/cleanup_empty_repos.rs +++ b/src/cleanup_empty_repos.rs @@ -344,18 +344,19 @@ pub async fn run(args: &CleanupArgs) -> Result<()> { /// /// Returns `(exists, is_empty)`: /// - `(false, true)` — path does not exist (treated as empty) -/// - `(true, true)` — path exists but `git for-each-ref` returns no output +/// - `(true, true)` — path exists but `git --git-dir= for-each-ref` returns no output /// - `(true, false)` — path exists and has at least one ref fn check_repo_empty(repo_path: &Path) -> (bool, bool) { if !repo_path.exists() { return (false, true); } - // Run `git for-each-ref --git-dir=` — empty output means no refs + // Run `git --git-dir= for-each-ref` — empty output means no refs. + // --git-dir must be a global option before the subcommand, not an argument to for-each-ref. let output = Command::new("git") - .args(["for-each-ref", "--format=%(refname)"]) .arg("--git-dir") .arg(repo_path) + .args(["for-each-ref", "--format=%(refname)"]) .output(); match output { -- cgit v1.2.3