From 8c0448f6c4384b07d57e6c0633e3f766d54d2ce2 Mon Sep 17 00:00:00 2001 From: Eliah Kagan Date: Fri, 26 Jul 2024 04:16:25 -0400 Subject: [PATCH 1/3] Warn about hidden worktrees as well as separate repos This slightly expands the wording of the warning suggesting to use `--skip-hidden-repositories`, so that it notes that worktrees and not just separate repositories are at stake. --- gitoxide-core/src/repository/clean.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitoxide-core/src/repository/clean.rs b/gitoxide-core/src/repository/clean.rs index b9bac90d9f3..8df3f7c8051 100644 --- a/gitoxide-core/src/repository/clean.rs +++ b/gitoxide-core/src/repository/clean.rs @@ -325,7 +325,7 @@ pub(crate) mod function { wrote_nl = true; writeln!( err, - "WARNING: would remove repositories hidden inside ignored directories - use --skip-hidden-repositories to skip{}", + "WARNING: would remove repositories and worktrees hidden inside ignored directories - use --skip-hidden-repositories to skip{}", wrap_in_parens(msg.take().unwrap_or_default()) )?; } From c241422dc64f97e9dc781465ae69130a423ee501 Mon Sep 17 00:00:00 2001 From: Eliah Kagan Date: Fri, 26 Jul 2024 04:20:31 -0400 Subject: [PATCH 2/3] fix: Clarify -r/--repositories and --skip-hidden-repositories This adds information to the help text for the `git clean` options `-r`/`--repositories` and `--skip-hidden-repositories` to make it clearer what their relationship is, avoid creating the false impression that repositories are never deleted in the absence of `-r`/`--repositories`, and note that `--skip-hidden-repositories` is sometimes needed to preserve not only separate repositories but the (probably rarer) case of hidden nested worktrees of the current repository. --- src/plumbing/options/mod.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/plumbing/options/mod.rs b/src/plumbing/options/mod.rs index eed07840aee..ad222e743f0 100644 --- a/src/plumbing/options/mod.rs +++ b/src/plumbing/options/mod.rs @@ -583,7 +583,7 @@ pub mod clean { /// Remove whole directories. #[arg(long, short = 'd')] pub directories: bool, - /// Remove nested repositories. + /// Remove nested repositories, even outside ignored directories. #[arg(long, short = 'r')] pub repositories: bool, /// Pathspec patterns are used to match the result of the dirwalk, not the dirwalk itself. @@ -592,7 +592,10 @@ pub mod clean { /// in reasonable, but often unexpected ways. #[arg(long, short = 'm')] pub pathspec_matches_result: bool, - /// Enter ignored directories to skip repositories contained within. + /// Enter ignored directories to skip repositories (and worktrees) contained within. + /// + /// This identifies and avoids deleting any unrelated repositories, or alternate worktrees + /// of this repository, that are nested inside ignored directories eligible for removal. #[arg(long)] pub skip_hidden_repositories: Option, /// What kind of repositories to find inside of untracked directories. From 6eb4ea6cf27b2feb3edb9dbf754393b0c7d272fd Mon Sep 17 00:00:00 2001 From: Eliah Kagan Date: Fri, 26 Jul 2024 05:10:16 -0400 Subject: [PATCH 3/3] fix: Adjust `gix clean` warning and help for worktree fix Since #1470 (for #1469), the repository's own nested worktrees are no longer removed when using `gix clean`, even if they are nested arbitarily under ignored directories. So no new mention of worktrees (separate from "repositories") in the help and warning message is accurate or required. This removes that, which means really we are keeping the warning message the same as it had been earlier, while still otherwise bringing in new explanatory text in the `gix clean` options help. --- gitoxide-core/src/repository/clean.rs | 2 +- src/plumbing/options/mod.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gitoxide-core/src/repository/clean.rs b/gitoxide-core/src/repository/clean.rs index 8df3f7c8051..b9bac90d9f3 100644 --- a/gitoxide-core/src/repository/clean.rs +++ b/gitoxide-core/src/repository/clean.rs @@ -325,7 +325,7 @@ pub(crate) mod function { wrote_nl = true; writeln!( err, - "WARNING: would remove repositories and worktrees hidden inside ignored directories - use --skip-hidden-repositories to skip{}", + "WARNING: would remove repositories hidden inside ignored directories - use --skip-hidden-repositories to skip{}", wrap_in_parens(msg.take().unwrap_or_default()) )?; } diff --git a/src/plumbing/options/mod.rs b/src/plumbing/options/mod.rs index ad222e743f0..cfbf0e705ff 100644 --- a/src/plumbing/options/mod.rs +++ b/src/plumbing/options/mod.rs @@ -592,10 +592,10 @@ pub mod clean { /// in reasonable, but often unexpected ways. #[arg(long, short = 'm')] pub pathspec_matches_result: bool, - /// Enter ignored directories to skip repositories (and worktrees) contained within. + /// Enter ignored directories to skip repositories contained within. /// - /// This identifies and avoids deleting any unrelated repositories, or alternate worktrees - /// of this repository, that are nested inside ignored directories eligible for removal. + /// This identifies and avoids deleting separate repositories that are nested inside + /// ignored directories eligible for removal. #[arg(long)] pub skip_hidden_repositories: Option, /// What kind of repositories to find inside of untracked directories.