git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git-clean: Fix error message if clean.requireForce is not set.

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 13, 2007, 05:11 UTC
Message-ID
<7v8x52zq46.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<47380E77.9040205@viscovery.net>
Johannes Sixt <j.sixt@viscovery.net> writes:
Show 7 quoted lines
> 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;
 
Previous: Pierre Habouzit
Message 5 of 5 in “git-clean: Fix error message if clean.requireForce is not set.”
  1. git-clean: Fix error message if clean.requireForce is not set.Johannes Sixt, Nov 12, 2007
  2. Pierre HabouzitNov 12, 2007
  3. Johannes SixtNov 12, 2007
  4. Pierre HabouzitNov 12, 2007
  5. Junio C HamanoNov 13, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.