From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: Re: [PATCH 1/1] clean: further clean-up of implementation around "--force"
Date: Sun, 03 Mar 2024 14:18:38 -0800 [thread overview]
Message-ID: <xmqq5xy3vu0x.fsf@gitster.g> (raw)
In-Reply-To: <20240303220600.2491792-2-gitster@pobox.com> (Junio C. Hamano's message of "Sun, 3 Mar 2024 14:06:00 -0800")
Junio C Hamano <gitster@pobox.com> writes:
> @@ -950,13 +950,8 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
> argc = parse_options(argc, argv, prefix, options, builtin_clean_usage,
> 0);
>
> - /* Dry run won't remove anything, so requiring force makes no sense */
> - if (dry_run)
> - require_force = 0;
> -
> - if (require_force != 0 && !force && !interactive)
> - die(_("clean.requireForce is true and neither -f nor -i given:"
> - " refusing to clean"));
> + if (require_force != 0 && !force && !interactive && !dry_run)
> + die(_("clean.requireForce is true and -f not given: refusing to clean"));
>
> if (force > 1)
> rm_flags = 0;
An obvious alternative way to clean-up the logic is to do this
instead:
if (dry_run || interactive))
require_force = 0;
if (require_force != 0 && !force)
die(_("clean.requireForce is true and ..."));
But as I wrote, the most important improvement done by Sergey's
patch was to remove the dual meaning of the "force" variable so that
it indicates if the "--force" option was given and nothing else,
while the "require_force" variable indicates if clean.requireForce
was given and nothing else. From that point of view, the
conditional tweaking done to require_force in the above alternative
makes the code worse, relative to Sergey's patch, and certainly to
its follow up, my patch about "--interactive".
next prev parent reply other threads:[~2024-03-03 22:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <7le6ziqzb.fsf_-_@osv.gnss.ru>
2024-03-03 22:05 ` [PATCH v2] clean: improve -n and -f implementation and documentation Junio C Hamano
2024-03-03 22:06 ` [PATCH 1/1] clean: further clean-up of implementation around "--force" Junio C Hamano
2024-03-03 22:18 ` Junio C Hamano [this message]
2024-03-04 18:46 ` Sergey Organov
2024-03-04 18:39 ` [PATCH v2] clean: improve -n and -f implementation and documentation Sergey Organov
2024-03-04 18:41 ` Junio C Hamano
2024-03-04 18:48 ` Sergey Organov
2024-03-04 19:03 ` Junio C Hamano
2024-03-04 20:19 ` 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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq5xy3vu0x.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).