Re: [BUG] submodule config does not apply to upper case submodules?

Subsystems: the rest

3 messages, 3 authors, 2017-02-15 · open the first message on its own page

Re: [BUG] submodule config does not apply to upper case submodules?

From: Junio C Hamano <hidden>
Date: 2017-02-15 23:11:40

Junio C Hamano [off-list ref] writes:
Jonathan Tan [off-list ref] writes:
quoted
I had some time to look into this, and yes, command-line parameters
are too aggressively downcased ("git_config_parse_parameter" calls
"strbuf_tolower" on the entire key part in config.c).
Ahh, thanks.  So this is not about submodules at all; it is -c var=VAL
where var is downcased too aggressively.
Perhaps something like this?

 config.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/config.c b/config.c
index c6b874a7bf..98bf8fee32 100644
--- a/config.c
+++ b/config.c
@@ -201,6 +201,20 @@ void git_config_push_parameter(const char *text)
 	strbuf_release(&env);
 }
 
+static void canonicalize_config_variable_name(struct strbuf *var)
+{
+	char *first_dot = strchr(var->buf, '.');
+	char *last_dot = strrchr(var->buf, '.');
+	char *cp;
+
+	if (first_dot)
+		for (cp = var->buf; *cp && cp < first_dot; cp++)
+			*cp = tolower(*cp);
+	if (last_dot)
+		for (cp = last_dot; *cp; cp++)
+			*cp = tolower(*cp);
+}
+
 int git_config_parse_parameter(const char *text,
 			       config_fn_t fn, void *data)
 {
@@ -223,7 +237,7 @@ int git_config_parse_parameter(const char *text,
 		strbuf_list_free(pair);
 		return error("bogus config parameter: %s", text);
 	}
-	strbuf_tolower(pair[0]);
+	canonicalize_config_variable_name(pair[0]);
 	if (fn(pair[0]->buf, value, data) < 0) {
 		strbuf_list_free(pair);
 		return -1;

Re: [BUG] submodule config does not apply to upper case submodules?

From: Stefan Beller <hidden>
Date: 2017-02-15 23:28:57

On Wed, Feb 15, 2017 at 3:11 PM, Junio C Hamano [off-list ref] wrote:
Junio C Hamano [off-list ref] writes:
quoted
Jonathan Tan [off-list ref] writes:
quoted
I had some time to look into this, and yes, command-line parameters
are too aggressively downcased ("git_config_parse_parameter" calls
"strbuf_tolower" on the entire key part in config.c).
Ahh, thanks.  So this is not about submodules at all; it is -c var=VAL
where var is downcased too aggressively.
Perhaps something like this?
Yes; though I'd place it in strbuf.{c,h} as it is operating
on the internals of the strbuf. (Do we make any promises outside of
strbuf about the internals? I mean we use .buf all the time, so maybe
I am overly cautious here)
quoted hunk
 config.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/config.c b/config.c
index c6b874a7bf..98bf8fee32 100644
--- a/config.c
+++ b/config.c
@@ -201,6 +201,20 @@ void git_config_push_parameter(const char *text)
        strbuf_release(&env);
 }

+static void canonicalize_config_variable_name(struct strbuf *var)
+{
+       char *first_dot = strchr(var->buf, '.');
+       char *last_dot = strrchr(var->buf, '.');
If first_dot != NULL, then last_dot !+ NULL as well.
(either both are NULL or none of them),
so we can loose one condition below.
+       char *cp;
+
+       if (first_dot)
+               for (cp = var->buf; *cp && cp < first_dot; cp++)
+                       *cp = tolower(*cp);
+       if (last_dot)
+               for (cp = last_dot; *cp; cp++)
+                       *cp = tolower(*cp);
+}
+
 int git_config_parse_parameter(const char *text,
                               config_fn_t fn, void *data)

Re: [BUG] submodule config does not apply to upper case submodules?

From: Jonathan Tan <hidden>
Date: 2017-02-15 23:33:28

On 02/15/2017 03:11 PM, Junio C Hamano wrote:
Junio C Hamano [off-list ref] writes:

Perhaps something like this?
This looks good. I was hoping to unify the processing logic between this 
CLI parsing and the usual stream parsing, but this approach is probably 
simpler.
quoted hunk
 config.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/config.c b/config.c
index c6b874a7bf..98bf8fee32 100644
--- a/config.c
+++ b/config.c
@@ -201,6 +201,20 @@ void git_config_push_parameter(const char *text)
 	strbuf_release(&env);
 }

+static void canonicalize_config_variable_name(struct strbuf *var)
+{
+	char *first_dot = strchr(var->buf, '.');
+	char *last_dot = strrchr(var->buf, '.');
+	char *cp;
+
+	if (first_dot)
+		for (cp = var->buf; *cp && cp < first_dot; cp++)
"*cp &&" is unnecessary, as far as I can tell.
quoted hunk
+			*cp = tolower(*cp);
+	if (last_dot)
+		for (cp = last_dot; *cp; cp++)
+			*cp = tolower(*cp);
+}
+
 int git_config_parse_parameter(const char *text,
 			       config_fn_t fn, void *data)
 {
@@ -223,7 +237,7 @@ int git_config_parse_parameter(const char *text,
 		strbuf_list_free(pair);
 		return error("bogus config parameter: %s", text);
 	}
-	strbuf_tolower(pair[0]);
+	canonicalize_config_variable_name(pair[0]);
 	if (fn(pair[0]->buf, value, data) < 0) {
 		strbuf_list_free(pair);
 		return -1;

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help