All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Jean-Noël Avila" <avila.jn@gmail.com>
Cc: Sergey Organov <sorganov@gmail.com>,  git@vger.kernel.org
Subject: Re: [PATCH] clean: improve -n and -f implementation and documentation
Date: Fri, 01 Mar 2024 10:07:20 -0800	[thread overview]
Message-ID: <xmqqmsrh6d2f.fsf@gitster.g> (raw)
In-Reply-To: <51a196c0-ea57-4ec5-99ea-c3f09cd90962@gmail.com> ("Jean-Noël Avila"'s message of "Fri, 1 Mar 2024 14:20:47 +0100")

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)".

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.

> 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.

Thanks.


  parent reply	other threads:[~2024-03-01 18:07 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-09 20:20 what should "git clean -n -f [-d] [-x] <pattern>" do? Junio C Hamano
2024-01-09 22:04 ` Sergey Organov
2024-01-19  2:07 ` Elijah Newren
2024-01-23 15:10   ` Sergey Organov
2024-01-23 18:34     ` Junio C Hamano
2024-01-24  8:23       ` Sergey Organov
2024-01-24 17:21         ` Junio C Hamano
2024-01-25 17:11           ` Sergey Organov
2024-01-25 17:46             ` Junio C Hamano
2024-01-25 20:27               ` Sergey Organov
2024-01-25 20:31                 ` Sergey Organov
2024-01-26  7:44                   ` Junio C Hamano
2024-01-26 12:09                     ` Sergey Organov
2024-01-27 10:00                       ` Junio C Hamano
2024-01-27 13:25                         ` Sergey Organov
2024-01-29 19:40                           ` Kristoffer Haugsbakk
2024-01-31 13:04                           ` Sergey Organov
2024-01-29  9:35                         ` Sergey Organov
2024-01-29 18:20                           ` Jeff King
2024-01-29 21:49                             ` Sergey Organov
2024-01-30  5:44                               ` Jeff King
2024-01-30  5:53                                 ` Junio C Hamano
2024-02-29 19:07 ` [PATCH] clean: improve -n and -f implementation and documentation Sergey Organov
2024-03-01 13:20   ` Jean-Noël Avila
2024-03-01 14:34     ` Sergey Organov
2024-03-01 15:29       ` Kristoffer Haugsbakk
2024-03-01 18:07         ` Junio C Hamano
2024-03-02 19:47       ` Jean-Noël AVILA
2024-03-02 20:09         ` Sergey Organov
2024-03-02 21:07           ` Junio C Hamano
2024-03-02 23:48             ` Sergey Organov
2024-03-03  9:54               ` Sergey Organov
2024-03-01 18:07     ` Junio C Hamano [this message]
2024-03-01 18:30       ` Junio C Hamano
2024-03-01 19:31       ` Sergey Organov
2024-03-02 16:31   ` Junio C Hamano
2024-03-02 19:59     ` Sergey Organov
2024-03-03  9:50   ` [PATCH v2] " Sergey Organov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqmsrh6d2f.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=avila.jn@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=sorganov@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.