diff options
| -rw-r--r-- | src/cleanup_empty_repos.rs | 7 |
1 files changed, 4 insertions, 3 deletions
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<()> { | |||
| 344 | /// | 344 | /// |
| 345 | /// Returns `(exists, is_empty)`: | 345 | /// Returns `(exists, is_empty)`: |
| 346 | /// - `(false, true)` — path does not exist (treated as empty) | 346 | /// - `(false, true)` — path does not exist (treated as empty) |
| 347 | /// - `(true, true)` — path exists but `git for-each-ref` returns no output | 347 | /// - `(true, true)` — path exists but `git --git-dir=<path> for-each-ref` returns no output |
| 348 | /// - `(true, false)` — path exists and has at least one ref | 348 | /// - `(true, false)` — path exists and has at least one ref |
| 349 | fn check_repo_empty(repo_path: &Path) -> (bool, bool) { | 349 | fn check_repo_empty(repo_path: &Path) -> (bool, bool) { |
| 350 | if !repo_path.exists() { | 350 | if !repo_path.exists() { |
| 351 | return (false, true); | 351 | return (false, true); |
| 352 | } | 352 | } |
| 353 | 353 | ||
| 354 | // Run `git for-each-ref --git-dir=<path>` — empty output means no refs | 354 | // Run `git --git-dir=<path> for-each-ref` — empty output means no refs. |
| 355 | // --git-dir must be a global option before the subcommand, not an argument to for-each-ref. | ||
| 355 | let output = Command::new("git") | 356 | let output = Command::new("git") |
| 356 | .args(["for-each-ref", "--format=%(refname)"]) | ||
| 357 | .arg("--git-dir") | 357 | .arg("--git-dir") |
| 358 | .arg(repo_path) | 358 | .arg(repo_path) |
| 359 | .args(["for-each-ref", "--format=%(refname)"]) | ||
| 359 | .output(); | 360 | .output(); |
| 360 | 361 | ||
| 361 | match output { | 362 | match output { |