diff mbox series

[1/2] clean: avoid looking for nested repository when appropriate

Message ID 20220215221615.20683-1-patrick.marlier@gmail.com (mailing list archive)
State New, archived
Headers show
Series [1/2] clean: avoid looking for nested repository when appropriate | expand

Commit Message

Patrick Marlier Feb. 15, 2022, 10:16 p.m. UTC
avoiding the unnecessary checks for is_nonbare_repository_dir() via setting DIR_NO_GITLINKS
---
 builtin/clean.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Elijah Newren Feb. 16, 2022, 4:09 a.m. UTC | #1
Hi,

On Tue, Feb 15, 2022 at 2:16 PM Patrick Marlier
<patrick.marlier@gmail.com> wrote:
>
> avoiding the unnecessary checks for is_nonbare_repository_dir() via setting DIR_NO_GITLINKS

Looks great, but a few details about commit messages that we like to see:

  * Please wrap commit messages at 72 characters
  * Describe your changes in imperative mood (i.e. "Avoid the
unnecessary" rather than "avoiding the unnecessary")
  * Use complete sentences for everything other than the subject.

So, perhaps:

"""
clean: avoid looking for nested repositories when unnecessary

With `git clean --ff` we will be deleting nested untracked repositories,
so there is no need to differentiate them from other untracked files.
Use the DIR_NO_GITLINKS flag in dir.flags to signify this and avoid the
is_nonbare_repository_dir() checks.
"""

> ---
>  builtin/clean.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/builtin/clean.c b/builtin/clean.c
> index 3ff02bbbff..18b37e3fd9 100644
> --- a/builtin/clean.c
> +++ b/builtin/clean.c
> @@ -955,9 +955,10 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
>                                   " refusing to clean"));
>         }
>
> -       if (force > 1)
> +       if (force > 1) {
>                 rm_flags = 0;
> -       else
> +               dir.flags |= DIR_NO_GITLINKS;
> +       } else
>                 dir.flags |= DIR_SKIP_NESTED_GIT;
>
>         dir.flags |= DIR_SHOW_OTHER_DIRECTORIES;
> --
> 2.35.1
diff mbox series

Patch

diff --git a/builtin/clean.c b/builtin/clean.c
index 3ff02bbbff..18b37e3fd9 100644
--- a/builtin/clean.c
+++ b/builtin/clean.c
@@ -955,9 +955,10 @@  int cmd_clean(int argc, const char **argv, const char *prefix)
 				  " refusing to clean"));
 	}
 
-	if (force > 1)
+	if (force > 1) {
 		rm_flags = 0;
-	else
+		dir.flags |= DIR_NO_GITLINKS;
+	} else
 		dir.flags |= DIR_SKIP_NESTED_GIT;
 
 	dir.flags |= DIR_SHOW_OTHER_DIRECTORIES;