summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 113f10f)
raw | patch | inline | side by side (parent: 113f10f)
author | Junio C Hamano <gitster@pobox.com> | |
Tue, 13 Nov 2007 05:13:05 +0000 (21:13 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 19 Nov 2007 03:11:42 +0000 (19:11 -0800) |
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>
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>
builtin-clean.c | patch | blob | history |
diff --git a/builtin-clean.c b/builtin-clean.c
index 55658e742fb0b8d23b9aa140c1d9cabeddd4b3d9..8da6f3c633dca7fbb5a0c06bc0ae2c2f71b6cc3f 100644 (file)
--- a/builtin-clean.c
+++ b/builtin-clean.c
#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>...",
{
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;
};
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));
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;