{"thread":{"id":"10821","subject":"[PATCH] git-clean: Fix error message if clean.requireForce is not set.","startedAt":"2007-11-12T08:27:35Z","lastAt":"2007-11-13T05:11:37Z","messageCount":5,"participants":["Johannes Sixt","Pierre Habouzit","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"59438","messageId":"47380E77.9040205@viscovery.net","threadId":"10821","inReplyTo":null,"subject":"[PATCH] git-clean: Fix error message if clean.requireForce is not set.","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2007-11-12T08:27:35Z","receivedAt":"2007-11-12T08:27:35Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"It was distracting to see this error message:\n\n     clean.requireForce set and -n or -f not given; refusing to clean\n\neven though clean.requireForce was not set at all. This patch distinguishes\nthe cases and gives a different message depending on whether the\nconfiguration variable is not set or set to true.\n\nWhile we are here, we also divert the error messages to stderr.\n\nSigned-off-by: Johannes Sixt <johannes.sixt@telecom.at>\n---\n  git-clean.sh |   24 +++++++++++++++---------\n  1 files changed, 15 insertions(+), 9 deletions(-)\n\ndiff --git a/git-clean.sh b/git-clean.sh\nindex f4965b8..7138fae 100755\n--- a/git-clean.sh\n+++ b/git-clean.sh\n@@ -25,10 +25,7 @@ rmrf=\"rm -rf --\"\n  rm_refuse=\"echo Not removing\"\n  echo1=\"echo\"\n\n-# requireForce used to default to false but now it defaults to true.\n-# IOW, lack of explicit \"clean.requireForce = false\" is taken as\n-# \"clean.requireForce = true\".\n-disabled=$(git config --bool clean.requireForce || echo true)\n+disabled=$(git config --bool clean.requireForce)\n\n  while test $# != 0\n  do\n@@ -37,10 +34,10 @@ do\n  \t\tcleandir=1\n  \t\t;;\n  \t-f)\n-\t\tdisabled=\n+\t\tdisabled=false\n  \t\t;;\n  \t-n)\n-\t\tdisabled=\n+\t\tdisabled=false\n  \t\trmf=\"echo Would remove\"\n  \t\trmrf=\"echo Would remove\"\n  \t\trm_refuse=\"echo Would not remove\"\n@@ -68,10 +65,19 @@ 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+# requireForce used to default to false but now it defaults to true.\n+# IOW, lack of explicit \"clean.requireForce = false\" is taken as\n+# \"clean.requireForce = true\".\n+case \"$disabled\" in\n+\"\")\n+\techo >&2 \"clean.requireForce not set and -n or -f not given; refusing to clean\"\n  \texit 1\n-fi\n+\t;;\n+\"true\")\n+\techo >&2 \"clean.requireForce set and -n or -f not given; refusing to clean\"\n+\texit 1\n+\t;;\n+esac\n\n  case \"$ignored,$ignoredonly\" in\n  \t1,1) usage;;\n-- \n1.5.3.5.1368.g3cabf\n"},{"id":"59439","messageId":"20071112083352.GA20482@artemis.corp","threadId":"10821","inReplyTo":"47380E77.9040205@viscovery.net","subject":"Re: [PATCH] git-clean: Fix error message if clean.requireForce is not set.","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-12T08:33:52Z","receivedAt":"2007-11-12T08:33:52Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"On Mon, Nov 12, 2007 at 08:27:35AM +0000, Johannes Sixt wrote:\n> It was distracting to see this error message:\n> \n>     clean.requireForce set and -n or -f not given; refusing to clean\n> \n> even though clean.requireForce was not set at all. This patch \n> distinguishes\n> the cases and gives a different message depending on whether the\n> configuration variable is not set or set to true.\n\n  Note that your patch won't apply to next as is :)\n\n-- \n·O·  Pierre Habouzit\n··O                                                madcoder@debian.org\nOOO                                                http://www.madism.org\n"},{"id":"59441","messageId":"4738119F.2030901@viscovery.net","threadId":"10821","inReplyTo":"20071112083352.GA20482@artemis.corp","subject":"Re: [PATCH] git-clean: Fix error message if clean.requireForce is not set.","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2007-11-12T08:41:03Z","receivedAt":"2007-11-12T08:41:03Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Pierre Habouzit schrieb:\n> On Mon, Nov 12, 2007 at 08:27:35AM +0000, Johannes Sixt wrote:\n>> It was distracting to see this error message:\n>>\n>>     clean.requireForce set and -n or -f not given; refusing to clean\n>>\n>> even though clean.requireForce was not set at all. This patch \n>> distinguishes\n>> the cases and gives a different message depending on whether the\n>> configuration variable is not set or set to true.\n> \n>   Note that your patch won't apply to next as is :)\n\nYou mean because of the builtinification of git-clean? I was hoping that \nShawn (Bohrer) is listening and will update his patch. ;) It has the same \nproblem.\n\n-- Hannes\n"},{"id":"59474","messageId":"20071112122423.GB20482@artemis.corp","threadId":"10821","inReplyTo":"4738119F.2030901@viscovery.net","subject":"Re: [PATCH] git-clean: Fix error message if clean.requireForce is not set.","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-12T12:24:23Z","receivedAt":"2007-11-12T12:24:23Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"On Mon, Nov 12, 2007 at 08:41:03AM +0000, Johannes Sixt wrote:\n> Pierre Habouzit schrieb:\n> >On Mon, Nov 12, 2007 at 08:27:35AM +0000, Johannes Sixt wrote:\n> >>It was distracting to see this error message:\n> >>\n> >>    clean.requireForce set and -n or -f not given; refusing to clean\n> >>\n> >>even though clean.requireForce was not set at all. This patch \n> >>distinguishes\n> >>the cases and gives a different message depending on whether the\n> >>configuration variable is not set or set to true.\n> >  Note that your patch won't apply to next as is :)\n> \n> You mean because of the builtinification of git-clean? I was hoping that \n> Shawn (Bohrer) is listening and will update his patch. ;) It has the same \n> problem.\n\n  No, afaict the builtin git-clean isn't in next yet. Though the\ngit-rev-parse --parseopt-ification is :)\n\n-- \n·O·  Pierre Habouzit\n··O                                                madcoder@debian.org\nOOO                                                http://www.madism.org\n"},{"id":"59618","messageId":"7v8x52zq46.fsf@gitster.siamese.dyndns.org","threadId":"10821","inReplyTo":"47380E77.9040205@viscovery.net","subject":"Re: [PATCH] git-clean: Fix error message if clean.requireForce is not set.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-13T05:11:37Z","receivedAt":"2007-11-13T05:11:37Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Sixt <j.sixt@viscovery.net> writes:\n\n> It was distracting to see this error message:\n>\n>     clean.requireForce set and -n or -f not given; refusing to clean\n>\n> even though clean.requireForce was not set at all. This patch distinguishes\n> the cases and gives a different message depending on whether the\n> configuration variable is not set or set to true.\n\nAnd this will be the counterpart for 'pu'...\n\n---\n\n builtin-clean.c |   12 +++++++++---\n 1 files changed, 9 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin-clean.c b/builtin-clean.c\nindex 55658e7..01fb887 100644\n--- a/builtin-clean.c\n+++ b/builtin-clean.c\n@@ -11,7 +11,7 @@\n #include \"dir.h\"\n #include \"parse-options.h\"\n \n-static int force;\n+static int force = -1; /* unset */\n \n static const char *const builtin_clean_usage[] = {\n \t\"git-clean [-d] [-f] [-n] [-q] [-x | -X] [--] <paths>...\",\n@@ -29,7 +29,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)\n {\n \tint j;\n \tint show_only = 0, remove_directories = 0, quiet = 0, ignored = 0;\n-\tint ignored_only = 0, baselen = 0;\n+\tint ignored_only = 0, baselen = 0, config_set = 0;\n \tstruct strbuf directory;\n \tstruct dir_struct dir;\n \tconst char *path, *base;\n@@ -49,6 +49,11 @@ int cmd_clean(int argc, const char **argv, const char *prefix)\n \tgit_config(git_clean_config);\n \targc = parse_options(argc, argv, options, builtin_clean_usage, 0);\n \n+\tif (force < 0)\n+\t\tforce = 0;\n+\telse\n+\t\tconfig_set = 1;\n+\n \tmemset(&dir, 0, sizeof(dir));\n \tif (ignored_only) {\n \t\tdir.show_ignored =1;\n@@ -59,7 +64,8 @@ int cmd_clean(int argc, const char **argv, const char *prefix)\n \t\tdie(\"-x and -X cannot be used together\");\n \n \tif (!show_only && !force)\n-\t\tdie(\"clean.requireForce set and -n or -f not given; refusing to clean\");\n+\t\tdie(\"clean.requireForce%s set and -n or -f not given; \"\n+\t\t    \"refusing to clean\", config_set ? \"\" : \" not\");\n \n \tdir.show_other_directories = 1;\n \n"}]}