Subject: Re: what should "git clean -n -f [-d] [-x] <pattern>" do?

From: Sergey Organov <[email-masked]>
Date: Tue, 23 Jan 2024 18:10:55 +0300

Elijah Newren <[email-masked]> writes:

> On Tue, Jan 9, 2024 at 12:21 PM Junio C Hamano <[email-masked]> wrote:
>>
>> I think the current code makes "-n" take precedence, and ignores
>> "-f".
>
> :-(
>
>>  Shouldn't it either
>>
>>  (1) error out with "-n and -f cannot be used together", or
>>  (2) let "-n" and "-f" follow the usual "last one wins" rule?
>
> I believe so.

Then how does one figure what "git clean -f -f" will do without actually
doing it?

Please notice that -f -f is special according to the manual:

  "Git will refuse to modify untracked nested git repositories
   (directories with a .git subdirectory) unless a second -f is given."

I looks like neither (0), nor (1) nor (2) gives us any useful behavior
in this case.

I figure the best solution is to rather make -n orthogonal to -f, that
will solve the puzzle, and that is what actually expected from a "dry
run" option: don't change any behavior, except print actions instead of
performing them.

-- Sergey Organov