summaryrefslogtreecommitdiff
path: root/builtin-clean.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2007-11-12 21:13:05 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2007-11-18 19:11:42 -0800
commit625db1b7530b621f32b0ef1ef502a09a05872f5d (patch)
tree1805dcd5be151310ca6ccbf6b54a1a4990bec69e /builtin-clean.c
parentMake git-clean a builtin (diff)
downloadtgif-625db1b7530b621f32b0ef1ef502a09a05872f5d.tar.xz
git-clean: Fix error message if clean.requireForce is not set.
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. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-clean.c')
-rw-r--r--builtin-clean.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/builtin-clean.c b/builtin-clean.c
index 55658e742f..8da6f3c633 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;
@@ -47,6 +47,11 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
};
git_config(git_clean_config);
+ if (force < 0)
+ force = 0;
+ else
+ config_set = 1;
+
argc = parse_options(argc, argv, options, builtin_clean_usage, 0);
memset(&dir, 0, sizeof(dir));
@@ -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;