{"thread":{"id":"7810","subject":"[PATCH] Add clean.requireForce option, and add -f option to git-clean to override it","startedAt":"2007-04-24T00:18:16Z","lastAt":"2007-04-24T02:05:41Z","messageCount":4,"participants":["Josh Triplett","Michael Spang"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"40267","messageId":"462D4CC8.70006@freedesktop.org","threadId":"7810","inReplyTo":null,"subject":"[PATCH] Add clean.requireForce option, and add -f option to git-clean to override it","fromName":"Josh Triplett","fromEmail":"josh@freedesktop.org","sentAt":"2007-04-24T00:18:16Z","receivedAt":"2007-04-24T00:18:16Z","isPatch":true,"sender":{"key":"josh@joshtriplett.org","avatar":"https://avatars.githubusercontent.com/u/162737?v=4"},"body":"Add a new configuration option clean.requireForce.  If set, git-clean will\nrefuse to run, unless forced with the new -f option, or not acting due to -n.\n\nSigned-off-by: Josh Triplett <josh@freedesktop.org>\n---\nPasses the test suite, and works fine for me.\n\n Documentation/config.txt               |    4 ++++\n Documentation/git-clean.txt            |    6 +++++-\n contrib/completion/git-completion.bash |    1 +\n git-clean.sh                           |   13 ++++++++++++-\n 4 files changed, 22 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex b13ff3a..e0aff53 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -300,6 +300,10 @@ branch.<name>.merge::\n \tbranch.<name>.merge to the desired branch, and use the special setting\n \t`.` (a period) for branch.<name>.remote.\n \n+clean.requireForce::\n+\tA boolean to make git-clean do nothing unless given -f or -n.  Defaults\n+\tto false.\n+\n color.branch::\n \tA boolean to enable/disable color in the output of\n \tgitlink:git-branch[1]. May be set to `true` (or `always`),\ndiff --git a/Documentation/git-clean.txt b/Documentation/git-clean.txt\nindex c61afbc..5aff026 100644\n--- a/Documentation/git-clean.txt\n+++ b/Documentation/git-clean.txt\n@@ -8,7 +8,7 @@ git-clean - Remove untracked files from the working tree\n SYNOPSIS\n --------\n [verse]\n-'git-clean' [-d] [-n] [-q] [-x | -X] [--] <paths>...\n+'git-clean' [-d] [-f] [-n] [-q] [-x | -X] [--] <paths>...\n \n DESCRIPTION\n -----------\n@@ -25,6 +25,10 @@ OPTIONS\n -d::\n \tRemove untracked directories in addition to untracked files.\n \n+-f::\n+\tIf the git configuration specifies clean.forceRequire as true,\n+\tgit-clean will refuse to run unless given -f or -n.\n+\n -n::\n \tDon't actually remove anything, just show what would be done.\n \ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 7c03403..46356e8 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -790,6 +790,7 @@ _git_config ()\n \t\tcore.legacyHeaders\n \t\tcore.packedGitWindowSize\n \t\tcore.packedGitLimit\n+\t\tclean.requireForce\n \t\tcolor.branch\n \t\tcolor.branch.current\n \t\tcolor.branch.local\ndiff --git a/git-clean.sh b/git-clean.sh\nindex db177a7..299309d 100755\n--- a/git-clean.sh\n+++ b/git-clean.sh\n@@ -3,9 +3,10 @@\n # Copyright (c) 2005-2006 Pavel Roskin\n #\n \n-USAGE=\"[-d] [-n] [-q] [-x | -X] [--] <paths>...\"\n+USAGE=\"[-d] [-f] [-n] [-q] [-x | -X] [--] <paths>...\"\n LONG_USAGE='Clean untracked files from the working directory\n \t-d\tremove directories as well\n+\t-f\toverride clean.requireForce and clean anyway\n \t-n \tdon'\\''t remove anything, just show what would be done\n \t-q\tbe quiet, only report errors\n \t-x\tremove ignored files as well\n@@ -19,6 +20,7 @@ require_work_tree\n ignored=\n ignoredonly=\n cleandir=\n+disabled=\"`git-config --bool clean.requireForce`\"\n rmf=\"rm -f --\"\n rmrf=\"rm -rf --\"\n rm_refuse=\"echo Not removing\"\n@@ -30,7 +32,11 @@ do\n \t-d)\n \t\tcleandir=1\n \t\t;;\n+\t-f)\n+\t\tdisabled=\n+\t\t;;\n \t-n)\n+\t\tdisabled=\n \t\trmf=\"echo Would remove\"\n \t\trmrf=\"echo Would remove\"\n \t\trm_refuse=\"echo Would not remove\"\n@@ -58,6 +64,11 @@ do\n \tshift\n done\n \n+if [ \"$disabled\" = true ]; then\n+\techo \"clean.requireForce set and -n or -f not given; refusing to clean\"\n+\texit 1\n+fi\n+\n case \"$ignored,$ignoredonly\" in\n \t1,1) usage;;\n esac\n-- \n1.5.1.1\n\n\n"},{"id":"40277","messageId":"462D5C4D.3050004@uwaterloo.ca","threadId":"7810","inReplyTo":"462D4CC8.70006@freedesktop.org","subject":"Re: [PATCH] Add clean.requireForce option, and add -f option to git-clean to override it","fromName":"Michael Spang","fromEmail":"mspang@uwaterloo.ca","sentAt":"2007-04-24T01:24:29Z","receivedAt":"2007-04-24T01:24:29Z","isPatch":true,"sender":{"key":"mspang@uwaterloo.ca","avatar":null},"body":"Josh Triplett wrote:\n> +if [ \"$disabled\" = true ]; then\n> +\techo \"clean.requireForce set and -n or -f not given; refusing to clean\"\n> +\texit 1\n> +fi\n\nHow is it useful to abort completely? Wouldn't it be better to behave like -n unless -f is given?\n\nCheers,\nMichael Spang\n"},{"id":"40280","messageId":"462D6589.7060206@freedesktop.org","threadId":"7810","inReplyTo":"462D5C4D.3050004@uwaterloo.ca","subject":"Re: [PATCH] Add clean.requireForce option, and add -f option to git-clean to override it","fromName":"Josh Triplett","fromEmail":"josh@freedesktop.org","sentAt":"2007-04-24T02:03:53Z","receivedAt":"2007-04-24T02:03:53Z","isPatch":true,"sender":{"key":"josh@joshtriplett.org","avatar":"https://avatars.githubusercontent.com/u/162737?v=4"},"body":"Michael Spang wrote:\n> Josh Triplett wrote:\n>> +if [ \"$disabled\" = true ]; then\n>> +\techo \"clean.requireForce set and -n or -f not given; refusing to clean\"\n>> +\texit 1\n>> +fi\n> \n> How is it useful to abort completely? Wouldn't it be better to behave\n> like -n unless -f is given?\n\nI don't think so, for a couple of reasons.\n\n* I want to make it really obvious that git-clean did nothing.  Spewing piles\n  of output quickly obscures the error message, and doesn't convey \"git-clean\n  did nothing\" at a glance.\n\n* -n takes time, especially with a large working copy.  Doing nothing takes\n  very little time.  The original use case motivating this patch came from the\n  idea of a git $HOME, and wanting to make sure git-clean won't delete\n  everything untracked in $HOME.  git-clean -n would take a long time here,\n  and I don't want to do it implicitly, particularly if I meant to clean a git\n  repository *under* $HOME.\n\n- Josh Triplett\n\n"},{"id":"40281","messageId":"462D65F5.4060405@freedesktop.org","threadId":"7810","inReplyTo":"462D6589.7060206@freedesktop.org","subject":"Re: [PATCH] Add clean.requireForce option, and add -f option to git-clean to override it","fromName":"Josh Triplett","fromEmail":"josh@freedesktop.org","sentAt":"2007-04-24T02:05:41Z","receivedAt":"2007-04-24T02:05:41Z","isPatch":true,"sender":{"key":"josh@joshtriplett.org","avatar":"https://avatars.githubusercontent.com/u/162737?v=4"},"body":"Josh Triplett wrote:\n> Michael Spang wrote:\n>> Josh Triplett wrote:\n>>> +if [ \"$disabled\" = true ]; then\n>>> +\techo \"clean.requireForce set and -n or -f not given; refusing to clean\"\n>>> +\texit 1\n>>> +fi\n>> How is it useful to abort completely? Wouldn't it be better to behave\n>> like -n unless -f is given?\n> \n> I don't think so, for a couple of reasons.\n[...]\n\nThat said, a *separate* config option to make git-clean assume -n by default\nseems potentially useful as well.\n\n- Josh Triplett\n\n"}]}