Re: [PATCH] clean: confirm before cleaning files and directories

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH] clean: confirm before cleaning files and directories

From: Matthieu Moy <hidden>
Date: 2016-06-15 22:57:01

Jiang Xin [off-list ref] writes:
Maybe we can do like this:

1. Set the default value of 'clean.requireForce' to false.
2. Show a error message and do nothing, if there is not 'clean.requireForce'
    setting, but the user called with a '--force' flag.
    ( like a transition for the change of push.default in git 2.0)
Perhaps introducing a new value for 'clean.requireForce':

$ git config --global clean.requireForce ask
$ git clean
will remove ...
are you sure [y/N]?

The error message when clean.requireForce is unset and --force is not
given could point the user to clean.requireForce=ask.

Then, maybe, later, this could become the default. But I tend to like
the non-interactive nature of most Git commands, so I'm a bit reluctant
here. My way of doing the confirmation dialog is

$ git clean -n
would remove ...
$ git clean -f

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

Re: [PATCH] clean: confirm before cleaning files and directories

From: Jiang Xin <hidden>
Date: 2016-06-15 22:57:01

2013/4/26 Matthieu Moy [off-list ref]:
Jiang Xin [off-list ref] writes:
quoted
Maybe we can do like this:

1. Set the default value of 'clean.requireForce' to false.
2. Show a error message and do nothing, if there is not 'clean.requireForce'
    setting, but the user called with a '--force' flag.
    ( like a transition for the change of push.default in git 2.0)
Perhaps introducing a new value for 'clean.requireForce':

$ git config --global clean.requireForce ask
$ git clean
.will remove ...
are you sure [y/N]?

The error message when clean.requireForce is unset and --force is not
given could point the user to clean.requireForce=ask.
Add new value for clean.requireForce would break old git clent.

   $ git clean
   fatal: bad config value for 'clean.requireforce' in .git/config
Then, maybe, later, this could become the default. But I tend to like
the non-interactive nature of most Git commands, so I'm a bit reluctant
here. My way of doing the confirmation dialog is

$ git clean -n
would remove ...
$ git clean -f
I try to put all cases in one table, but still looks weird.

    | clean.requireForce  |     git clean     | git clean --force |
    +---------------------+-------------------|-------------------|
    | TRUE                | error             | delete...         |
    +---------------------+-------------------|-------------------|
    | FALSE               | delete...         | delete...         |
    +---------------------+-------------------|-------------------|
    | unset               | confirm           | warn + confirm    |
    +---------------------+-------------------|-------------------|

Does anyone really set and use "clean.requireForce" setting?
And if there is a confirm dialog, do we need 'clean.requireForce' any more?
Or we can add a `--no-ask` option, in order to override the confirm dialog.

--
Matthieu Moy
http://www-verimag.imag.fr/~moy/


--
蒋鑫

北京群英汇信息技术有限公司
邮件: worldhello.net@gmail.com
网址: http://www.ossxp.com/
博客: http://www.worldhello.net/
微博: http://weibo.com/gotgit/
电话: 18601196889
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help