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

From: Junio C Hamano <[email-masked]>
Date: Sat, 27 Jan 2024 02:00:02 -0800

Sergey Organov <[email-masked]> writes:

> I'm still arguing in favor of fixing "-n", and I believe a fix is needed
> independently from decision about "-f -f".

Even though I do not personally like it, I do not think "which
between do-it (f) and do-not-do-it (n) do you want to use?" is
broken.  It sometimes irritates me to find "git clean" (without "-f"
or "-n", and with clean.requireForce not disabled) complain, and I
personally think "git clean" when clean.requireForce is in effect
and no "-n" or "-f" were given should pretend as if "-n" were given.
I wish if it were "without -n or -f, we pretend as if -n were given,
possibly with a warning that says 'you need -f if you actually want
to carry out these operations'".

But that is a separate usability issue.

What I find broken is that giving one 'f' and one 'n' in different
order, i.e. "-f -n" and "-n -f", does not do what I expect.  If you
are choosing between do-it (f) and do-not-do-it (n), you ought to be
able to rely on the usual last-one-wins rule.  That I find broken.

The mistake[*] of "-f -f" is rather obvious, given that the other
"normal" ways to tweak what is affected by the command are done as
"what else do we clean? directories (d)? ignored (x)?..." options.
When we add the upcoming "precious" bit support, we should make sure
that the way to trigger "oh, by the way, please clobber those paths
that are marked precious, too" is not by giving three '-f'.  It
would make it impossible to ask for that without also removing
nested repositories, which takes two '-f'.

[Footnote]

 * To a lessor extent, the -v (verbose) option shares the same
   problem as "-f -f" here, in that its worldview is to assume that
   a single "verbosity level" is sufficient.  Unlike the severity
   level thing, however, the user who wanted to see only messages
   about X but have to also see messages about Y and Z that are at
   the same or lessor verbosity level as X can filter out unwanted
   messages without causing a real harm.