Re: [PATCH] clean: improve -n and -f implementation and documentation
- From
Sergey Organov <sorganov@gmail.com>
- Date
- Mar 1, 2024, 19:31 UTC
- Message-ID
- <878r31n3zj.fsf@osv.gnss.ru>
- In-Reply-To
- <xmqqmsrh6d2f.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 7 quoted lines
> Jean-Noël Avila <avila.jn@gmail.com> writes: > >>> + /* Dry run won't remove anything, so requiring force makes no sense */ >>> + if(dry_run) >>> + require_force = 0; > > Style. "if (dry_run)".
Ooops!
Show 35 quoted lines
>
> Getting rid of "config_set", which was an extra variable that kept
> track of where "force" came from, does make the logic cleaner, I
> guess. What we want to happen is that one of -i/-n/-f is required
> when clean.requireForce is *not* unset (i.e. 0 <= require_force).
>
>>> + if (!force && !interactive) {
>
> The require-force takes effect only when neither force or
> interactive is given, so the new code structure puts the above
> obvious conditional around "do we complain due to requireForce?"
> logic. Sensible.
>
>>> + if (require_force > 0)
>>> + die(_("clean.requireForce set to true and neither -f, nor -i given; "
>>> + "refusing to clean"));
>
> If it is explicitly set, we get this message. And ...
>
>>> + else if (require_force < 0)
>>> + die(_("clean.requireForce defaults to true and neither -f, nor -i given; "
>>> "refusing to clean"));
>
> ... if it is set due to default (in other words, if it is not unset), we
> get this message.
>
> As you said, I do not think it matters too much either way to the
> end-users where the truth setting of clean.requireForce came from,
> either due to the default or the user explicitly configuring. So
> unifying to a single message may be helpful to both readers and
> translators.
>
> clean.requireForce is true; unless interactive, -f is required
>
> might be a bit shorter and more to the point.Dunno, I tried to keep changes to the bare sensible minimum, especially to avoid possible controversy. I'd leave this for somebody else to decide upon and patch, if they feel like it.
Show 5 quoted lines
>> The last two cases can be coalesced into a single case (the last one), >> because the difference in the messages does not bring more information >> to the user. > > Yeah.
"The last two cases" sounds like there are more of them, and there is none, so to me it sounded like patch misread. Maybe I'm wrong.
Thanks for the review!
-- Sergey Organov