diff mbox series

[4/6] config: move quote_path_fully to global config

Message ID 15d65d3e05d11de69e36f2a7b83c06b2727ff8f1.1685716420.git.gitgitgadget@gmail.com (mailing list archive)
State New, archived
Headers show
Series Lazy-loaded default Git config | expand

Commit Message

Derrick Stolee June 2, 2023, 2:33 p.m. UTC
From: Derrick Stolee <derrickstolee@github.com>

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
---
 config.c        | 5 -----
 global-config.c | 2 ++
 global-config.h | 1 +
 quote.c         | 6 +++---
 quote.h         | 2 --
 5 files changed, 6 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/config.c b/config.c
index d955a16b372..6b4051a4eae 100644
--- a/config.c
+++ b/config.c
@@ -1568,11 +1568,6 @@  static int git_default_core_config(const char *var, const char *value, void *cb)
 			check_stat = 0;
 	}
 
-	if (!strcmp(var, "core.quotepath")) {
-		quote_path_fully = git_config_bool(var, value);
-		return 0;
-	}
-
 	if (!strcmp(var, "core.symlinks")) {
 		has_symlinks = git_config_bool(var, value);
 		return 0;
diff --git a/global-config.c b/global-config.c
index 5bd6bc45418..395d21e0381 100644
--- a/global-config.c
+++ b/global-config.c
@@ -6,6 +6,7 @@  static int global_ints[] = {
 	[INT_CONFIG_NONE] = 0, /* unused*/
 	[INT_CONFIG_TRUST_EXECUTABLE_BIT] = 1,
 	[INT_CONFIG_TRUST_CTIME] = 1,
+	[INT_CONFIG_QUOTE_PATH_FULLY] = 1,
 };
 
 /* Bitmask for the enum. */
@@ -15,6 +16,7 @@  static const char *global_int_names[] = {
 	[INT_CONFIG_NONE] = NULL, /* unused*/
 	[INT_CONFIG_TRUST_EXECUTABLE_BIT] = "core.filemode",
 	[INT_CONFIG_TRUST_CTIME] = "core.trustctime",
+	[INT_CONFIG_QUOTE_PATH_FULLY] = "core.quotepath",
 };
 
 static int config_available;
diff --git a/global-config.h b/global-config.h
index a6d8e5adc4e..fbe5fccb1a1 100644
--- a/global-config.h
+++ b/global-config.h
@@ -5,6 +5,7 @@  enum int_config_key {
 	INT_CONFIG_NONE = 0,
 	INT_CONFIG_TRUST_EXECUTABLE_BIT,
 	INT_CONFIG_TRUST_CTIME,
+	INT_CONFIG_QUOTE_PATH_FULLY,
 };
 
 /**
diff --git a/quote.c b/quote.c
index 43c739671ed..25ca0473881 100644
--- a/quote.c
+++ b/quote.c
@@ -4,8 +4,7 @@ 
 #include "quote.h"
 #include "strbuf.h"
 #include "strvec.h"
-
-int quote_path_fully = 1;
+#include "global-config.h"
 
 static inline int need_bs_quote(char c)
 {
@@ -212,7 +211,7 @@  int sq_dequote_to_strvec(char *arg, struct strvec *array)
 }
 
 /* 1 means: quote as octal
- * 0 means: quote as octal if (quote_path_fully)
+ * 0 means: quote as octal if core.quotePath is true
  * -1 means: never quote
  * c: quote as "\\c"
  */
@@ -233,6 +232,7 @@  static signed char const cq_lookup[256] = {
 
 static inline int cq_must_quote(char c)
 {
+	int quote_path_fully = get_int_config_global(INT_CONFIG_QUOTE_PATH_FULLY);
 	return cq_lookup[(unsigned char)c] + quote_path_fully > 0;
 }
 
diff --git a/quote.h b/quote.h
index 0300c291041..87ff458b06d 100644
--- a/quote.h
+++ b/quote.h
@@ -3,8 +3,6 @@ 
 
 struct strbuf;
 
-extern int quote_path_fully;
-
 /* Help to copy the thing properly quoted for the shell safety.
  * any single quote is replaced with '\'', any exclamation point
  * is replaced with '\!', and the whole thing is enclosed in a