* [PATCH] git-clean: Fix error message if clean.requireForce is not set.
@ 2007-11-12 8:27 Johannes Sixt
2007-11-12 8:33 ` Pierre Habouzit
2007-11-13 5:11 ` Junio C Hamano
0 siblings, 2 replies; 5+ messages in thread
From: Johannes Sixt @ 2007-11-12 8:27 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Git Mailing List
It was distracting to see this error message:
clean.requireForce set and -n or -f not given; refusing to clean
even though clean.requireForce was not set at all. This patch distinguishes
the cases and gives a different message depending on whether the
configuration variable is not set or set to true.
While we are here, we also divert the error messages to stderr.
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
---
git-clean.sh | 24 +++++++++++++++---------
1 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/git-clean.sh b/git-clean.sh
index f4965b8..7138fae 100755
--- a/git-clean.sh
+++ b/git-clean.sh
@@ -25,10 +25,7 @@ rmrf="rm -rf --"
rm_refuse="echo Not removing"
echo1="echo"
-# requireForce used to default to false but now it defaults to true.
-# IOW, lack of explicit "clean.requireForce = false" is taken as
-# "clean.requireForce = true".
-disabled=$(git config --bool clean.requireForce || echo true)
+disabled=$(git config --bool clean.requireForce)
while test $# != 0
do
@@ -37,10 +34,10 @@ do
cleandir=1
;;
-f)
- disabled=
+ disabled=false
;;
-n)
- disabled=
+ disabled=false
rmf="echo Would remove"
rmrf="echo Would remove"
rm_refuse="echo Would not remove"
@@ -68,10 +65,19 @@ do
shift
done
-if [ "$disabled" = true ]; then
- echo "clean.requireForce set and -n or -f not given; refusing to clean"
+# requireForce used to default to false but now it defaults to true.
+# IOW, lack of explicit "clean.requireForce = false" is taken as
+# "clean.requireForce = true".
+case "$disabled" in
+"")
+ echo >&2 "clean.requireForce not set and -n or -f not given; refusing to clean"
exit 1
-fi
+ ;;
+"true")
+ echo >&2 "clean.requireForce set and -n or -f not given; refusing to clean"
+ exit 1
+ ;;
+esac
case "$ignored,$ignoredonly" in
1,1) usage;;
--
1.5.3.5.1368.g3cabf
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] git-clean: Fix error message if clean.requireForce is not set. 2007-11-12 8:27 [PATCH] git-clean: Fix error message if clean.requireForce is not set Johannes Sixt @ 2007-11-12 8:33 ` Pierre Habouzit 2007-11-12 8:41 ` Johannes Sixt 2007-11-13 5:11 ` Junio C Hamano 1 sibling, 1 reply; 5+ messages in thread From: Pierre Habouzit @ 2007-11-12 8:33 UTC (permalink / raw) To: Johannes Sixt; +Cc: Junio C Hamano, Git Mailing List [-- Attachment #1: Type: text/plain, Size: 631 bytes --] On Mon, Nov 12, 2007 at 08:27:35AM +0000, Johannes Sixt wrote: > It was distracting to see this error message: > > clean.requireForce set and -n or -f not given; refusing to clean > > even though clean.requireForce was not set at all. This patch > distinguishes > the cases and gives a different message depending on whether the > configuration variable is not set or set to true. Note that your patch won't apply to next as is :) -- ·O· Pierre Habouzit ··O madcoder@debian.org OOO http://www.madism.org [-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] git-clean: Fix error message if clean.requireForce is not set. 2007-11-12 8:33 ` Pierre Habouzit @ 2007-11-12 8:41 ` Johannes Sixt 2007-11-12 12:24 ` Pierre Habouzit 0 siblings, 1 reply; 5+ messages in thread From: Johannes Sixt @ 2007-11-12 8:41 UTC (permalink / raw) To: Pierre Habouzit; +Cc: Junio C Hamano, Git Mailing List, Shawn Bohrer Pierre Habouzit schrieb: > On Mon, Nov 12, 2007 at 08:27:35AM +0000, Johannes Sixt wrote: >> It was distracting to see this error message: >> >> clean.requireForce set and -n or -f not given; refusing to clean >> >> even though clean.requireForce was not set at all. This patch >> distinguishes >> the cases and gives a different message depending on whether the >> configuration variable is not set or set to true. > > Note that your patch won't apply to next as is :) You mean because of the builtinification of git-clean? I was hoping that Shawn (Bohrer) is listening and will update his patch. ;) It has the same problem. -- Hannes ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] git-clean: Fix error message if clean.requireForce is not set. 2007-11-12 8:41 ` Johannes Sixt @ 2007-11-12 12:24 ` Pierre Habouzit 0 siblings, 0 replies; 5+ messages in thread From: Pierre Habouzit @ 2007-11-12 12:24 UTC (permalink / raw) To: Johannes Sixt; +Cc: Junio C Hamano, Git Mailing List, Shawn Bohrer [-- Attachment #1: Type: text/plain, Size: 1024 bytes --] On Mon, Nov 12, 2007 at 08:41:03AM +0000, Johannes Sixt wrote: > Pierre Habouzit schrieb: > >On Mon, Nov 12, 2007 at 08:27:35AM +0000, Johannes Sixt wrote: > >>It was distracting to see this error message: > >> > >> clean.requireForce set and -n or -f not given; refusing to clean > >> > >>even though clean.requireForce was not set at all. This patch > >>distinguishes > >>the cases and gives a different message depending on whether the > >>configuration variable is not set or set to true. > > Note that your patch won't apply to next as is :) > > You mean because of the builtinification of git-clean? I was hoping that > Shawn (Bohrer) is listening and will update his patch. ;) It has the same > problem. No, afaict the builtin git-clean isn't in next yet. Though the git-rev-parse --parseopt-ification is :) -- ·O· Pierre Habouzit ··O madcoder@debian.org OOO http://www.madism.org [-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] git-clean: Fix error message if clean.requireForce is not set. 2007-11-12 8:27 [PATCH] git-clean: Fix error message if clean.requireForce is not set Johannes Sixt 2007-11-12 8:33 ` Pierre Habouzit @ 2007-11-13 5:11 ` Junio C Hamano 1 sibling, 0 replies; 5+ messages in thread From: Junio C Hamano @ 2007-11-13 5:11 UTC (permalink / raw) To: Johannes Sixt; +Cc: Git Mailing List, Shawn Bohrer Johannes Sixt <j.sixt@viscovery.net> writes: > It was distracting to see this error message: > > clean.requireForce set and -n or -f not given; refusing to clean > > even though clean.requireForce was not set at all. This patch distinguishes > the cases and gives a different message depending on whether the > configuration variable is not set or set to true. And this will be the counterpart for 'pu'... --- builtin-clean.c | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-) diff --git a/builtin-clean.c b/builtin-clean.c index 55658e7..01fb887 100644 --- a/builtin-clean.c +++ b/builtin-clean.c @@ -11,7 +11,7 @@ #include "dir.h" #include "parse-options.h" -static int force; +static int force = -1; /* unset */ static const char *const builtin_clean_usage[] = { "git-clean [-d] [-f] [-n] [-q] [-x | -X] [--] <paths>...", @@ -29,7 +29,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix) { int j; int show_only = 0, remove_directories = 0, quiet = 0, ignored = 0; - int ignored_only = 0, baselen = 0; + int ignored_only = 0, baselen = 0, config_set = 0; struct strbuf directory; struct dir_struct dir; const char *path, *base; @@ -49,6 +49,11 @@ int cmd_clean(int argc, const char **argv, const char *prefix) git_config(git_clean_config); argc = parse_options(argc, argv, options, builtin_clean_usage, 0); + if (force < 0) + force = 0; + else + config_set = 1; + memset(&dir, 0, sizeof(dir)); if (ignored_only) { dir.show_ignored =1; @@ -59,7 +64,8 @@ int cmd_clean(int argc, const char **argv, const char *prefix) die("-x and -X cannot be used together"); if (!show_only && !force) - die("clean.requireForce set and -n or -f not given; refusing to clean"); + die("clean.requireForce%s set and -n or -f not given; " + "refusing to clean", config_set ? "" : " not"); dir.show_other_directories = 1; ^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-11-13 5:12 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-11-12 8:27 [PATCH] git-clean: Fix error message if clean.requireForce is not set Johannes Sixt 2007-11-12 8:33 ` Pierre Habouzit 2007-11-12 8:41 ` Johannes Sixt 2007-11-12 12:24 ` Pierre Habouzit 2007-11-13 5:11 ` Junio C Hamano
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.