Subject: Re: [PATCH 2/3] sparse-checkout: add 'clean' command

From: Junio C Hamano <[email-masked]>
Date: Tue, 08 Jul 2025 13:30:37 -0700

Patrick Steinhardt <[email-masked]> writes:

> On Tue, Jul 08, 2025 at 11:19:52AM +0000, Derrick Stolee via GitGitGadget wrote:
>> diff --git a/Documentation/git-sparse-checkout.adoc b/Documentation/git-sparse-checkout.adoc
>> index 529a8edd9c1e..21ba6f759905 100644
>> --- a/Documentation/git-sparse-checkout.adoc
>> +++ b/Documentation/git-sparse-checkout.adoc
>> @@ -111,6 +111,17 @@ flags, with the same meaning as the flags from the `set` command, in order
>>  to change which sparsity mode you are using without needing to also respecify
>>  all sparsity paths.
>>  
>> +'clean'::
>> +	Remove all files in tracked directories that are outside of the
>> +	sparse-checkout definition. This subcommand requires cone-mode
>> +	sparse-checkout to be sure that we know which directories are
>> +	both tracked and all contained paths are not in the sparse-checkout.
>> +	This command can be used to be sure the sparse index works
>> +	efficiently.
>> ++
>> +The `clean` command can also take the `--dry-run` (`-n`) option to list
>> +the directories it would remove without performing any filesystem changes.
>> +
>
> Hm. This is somewhat different from `git clean`, where you have to pass
> `-f` to make it delete any data. I'm not particularly a fan of that
> mode, but should we maybe retain it regardless to ensure that things are
> at least a tiny bit more consistent?

Ah, it reminds me of my favorite "regret".  We may want to consider
making the --force/--dry-run used in "git clean" saner at a major
version boundary.  I am not particulary a fan of that mode, and
would oppose a patch made as a part of regular "let's change this,
as I do not like it" exercise, but as a known-breaking change, I do
not mind it at all.  Essentially the change to propose would be to
deprecate clean.requireForce and internally make it a constant
false.

But that is a tangent ;-)