git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Sixt <j.sixt@viscovery.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: [PATCH] git-clean: Fix error message if clean.requireForce is not set.
Date: Mon, 12 Nov 2007 09:27:35 +0100	[thread overview]
Message-ID: <47380E77.9040205@viscovery.net> (raw)

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

             reply	other threads:[~2007-11-12  8:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-12  8:27 Johannes Sixt [this message]
2007-11-12  8:33 ` [PATCH] git-clean: Fix error message if clean.requireForce is not set Pierre Habouzit
2007-11-12  8:41   ` Johannes Sixt
2007-11-12 12:24     ` Pierre Habouzit
2007-11-13  5:11 ` Junio C Hamano

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47380E77.9040205@viscovery.net \
    --to=j.sixt@viscovery.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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.
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 NNTP newsgroup(s).