From: "Kristoffer Haugsbakk" <code@khaugsbakk.name>
To: "Sergey Organov" <sorganov@gmail.com>
Cc: "Elijah Newren" <newren@gmail.com>,
git@vger.kernel.org, "Junio C Hamano" <gitster@pobox.com>
Subject: Re: what should "git clean -n -f [-d] [-x] <pattern>" do?
Date: Mon, 29 Jan 2024 20:40:42 +0100 [thread overview]
Message-ID: <7f97e5e4-c394-4403-94f1-6163fbd02e88@app.fastmail.com> (raw)
In-Reply-To: <87il3enc1i.fsf@osv.gnss.ru>
On Sat, Jan 27, 2024, at 14:25, Sergey Organov wrote:
> Junio C Hamano <gitster@pobox.com> writes:
>
>> Sergey Organov <sorganov@gmail.com> writes:
I agree with Sergey.
Let’s suppose I’ve never used git-clean(1) (and I almost never use
it). I read the man page to find out what it’s about. Oh, it removes
files that I haven’t tracked. That sounds dangerous. But I see under
`-n, --dry-run` that I can simulate what it would do:
“ Don’t actually remove anything, just show what would be done.
Great, this is what I want. So this seems to mean to run `git clean` and
just tell me what would happen. But now I’ve already read that it
requires `--force` in order to do anything. Which means that I don’t
want to just run:
```
git clean --dry-run
```
Since I presume that would give me the “no `--force` provided”
error. Which means that I want to tack on `--force`:
```
git clean --dry-run --force
```
Now I figure that this will run `git clean --force` but switch real
deletion with printing the filenames.[1]
Junio wrote:
> 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.
Now suppose I have noticed that some git(1) commands have these
`--[no-]do-it` options. I know that I can leverage this to override a
previous option. And that is useful when I for example have an alias
with `--do-it` but for this invocation I want `--no-do-it`. I read about
`--force` here but see that there is no `--no-force`. I then assume that
the only things that have to do with `--force` or not is that option and
the `requireForce` configuration variable.
I’ve also seen `--force` in other git(1) commands. And they usually are
about some specific scenario rather than the whole command itself, since
e.g. committing one too many times doesn’t really hurt. But I understand
how `--force` applies to all the useful work that git-clean(1) does
because all the useful work is also destructive work. So this is what I
expect from these options in general:
1. `--force`: require for the subset of actions that are potentially
dangerous or may be unwanted in some way
2. `--dry-run`: simulate the action (specifically print everything that
would happen but don’t do anything to `.git`, to untracked files, or
anything else)
And I expect these two to be orthogonal. Because I might want—if the
option is there—to simulate some `--force` (e.g. `git push --force`)
with a `--dry-run`. As in: what would be printed? I wouldn’t expect
`--force` to override `--dry-run`.
† 1: I’m never this careful in real life. But this is about deleting
files without any (from Git) recovery so I guess some prudence is
required in this case.
--
Kristoffer Haugsbakk
next prev parent reply other threads:[~2024-01-29 19:41 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 [this message]
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
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
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=7f97e5e4-c394-4403-94f1-6163fbd02e88@app.fastmail.com \
--to=code@khaugsbakk.name \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=newren@gmail.com \
--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.
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).