From: Junio C Hamano <gitster@pobox.com>
To: Johannes Sixt <j.sixt@viscovery.net>
Cc: Git Mailing List <git@vger.kernel.org>,
Shawn Bohrer <shawn.bohrer@gmail.com>
Subject: Re: [PATCH] git-clean: Fix error message if clean.requireForce is not set.
Date: Mon, 12 Nov 2007 21:11:37 -0800 [thread overview]
Message-ID: <7v8x52zq46.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <47380E77.9040205@viscovery.net> (Johannes Sixt's message of "Mon, 12 Nov 2007 09:27:35 +0100")
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;
prev parent reply other threads:[~2007-11-13 5:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
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=7v8x52zq46.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=j.sixt@viscovery.net \
--cc=shawn.bohrer@gmail.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).