Skip to contentSkip to conversation

submodule-config: correct error reporting for invalid ignore value

PATCH In review Stefan Beller 2 participants 5 messages Mar 14, 2017 – Mar 15, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 submodule-config: correct error reporting for invalid ignore value

As 'var' contains the whole value we get error messages that repeat the section and key currently:

warning: Invalid parameter 'true' for config option 'submodule.submodule.plugins/hooks.ignore.ignore'

Fix this by only giving the section name in the warning.

---
 submodule-config.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
submodule-config.c +1 -1
index 93453909cf..bb069bc097 100644
@@ -333,7 +333,7 @@ static int parse_config(const char *var, const char *value, void *data)
 			 strcmp(value, "all") &&
 			 strcmp(value, "none"))
 			warning("Invalid parameter '%s' for config option "
-					"'submodule.%s.ignore'", value, var);
+					"'submodule.%s.ignore'", value, name.buf);
 		else {
 			free((void *) submodule->ignore);
 			submodule->ignore = xstrdup(value);
Signature · 1 line
2.12.0.264.gd6db3f2165.dirty
#1 lore raw
Quoted 17 lines · Stefan Beller

As 'var' contains the whole value we get error messages that repeat the section and key currently:

warning: Invalid parameter 'true' for config option 'submodule.submodule.plugins/hooks.ignore.ignore'

Fix this by only giving the section name in the warning.

---
 submodule-config.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
submodule-config.c +0 -0
index 93453909cf..bb069bc097 100644

submodule-config.c static int parse_config(const char *var, const char *value, void *data) · line 336

Quoted 5 lines
submodule-config.c +1 -1
@@ -333,7 +333,7 @@ static int parse_config(const char *var, const char *value, void *data)
 			 strcmp(value, "all") &&
 			 strcmp(value, "none"))
 			warning("Invalid parameter '%s' for config option "
-					"'submodule.%s.ignore'", value, var);
+					"'submodule.%s.ignore'", value, name.buf);

Obviously correct. Nobody seems to have complained about this since it was first written in 2.6 days, which is a bit sad, though.

Thanks.

#2 lore raw
Quoted 28 lines · Junio C Hamano
Quoted 17 lines · Stefan Beller

As 'var' contains the whole value we get error messages that repeat the section and key currently:

warning: Invalid parameter 'true' for config option 'submodule.submodule.plugins/hooks.ignore.ignore'

Fix this by only giving the section name in the warning.

---
 submodule-config.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
submodule-config.c +0 -0
index 93453909cf..bb069bc097 100644

submodule-config.c static int parse_config(const char *var, const char *value, void *data) · line 336

Quoted 5 lines
submodule-config.c +1 -1
@@ -333,7 +333,7 @@ static int parse_config(const char *var, const char *value, void *data)
                       strcmp(value, "all") &&
                       strcmp(value, "none"))
                      warning("Invalid parameter '%s' for config option "
-                                     "'submodule.%s.ignore'", value, var);
+                                     "'submodule.%s.ignore'", value, name.buf);

Obviously correct. Nobody seems to have complained about this since it was first written in 2.6 days, which is a bit sad, though.

Quoted 1 line

Thanks.

https://trends.google.com/trends/explore?date=all&q=submodule,%2Fm%2F05vqwg
(Comparing "Submodule" (search term) with "Git" (System Software) over 10 years)

#TiL
* submodule searches are less than 1% of Git searches, so not a lot of users compared to Git itself.
* submodules are only used in larger countries unlike Git, which is used in a lot more countries (well, that may be displaying issues)
* submodules are a German thing (relatively speaking) followed by Russia, US, Canada, Australia, Japan.

:-)

#3 lore raw
In reply to Junio C Hamano
Quoted 14 lines · Junio C Hamano
Quoted 12 lines · Stefan Beller

As 'var' contains the whole value we get error messages that repeat the section and key currently:

warning: Invalid parameter 'true' for config option 'submodule.submodule.plugins/hooks.ignore.ignore'

Fix this by only giving the section name in the warning.

---
 submodule-config.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines

submodule-config.c static int parse_config(const char *var, const char *value, void *data) · line 336

Quoted 10 lines
submodule-config.c +1 -1
index 93453909cf..bb069bc097 100644
@@ -333,7 +333,7 @@ static int parse_config(const char *var, const char *value, void *data)
 			 strcmp(value, "all") &&
 			 strcmp(value, "none"))
 			warning("Invalid parameter '%s' for config option "
-					"'submodule.%s.ignore'", value, var);
+					"'submodule.%s.ignore'", value, name.buf);

Obviously correct.

But isn't this even more obviously correct?

	warning("invalid parameter '%s' for option %s", value, var);
#4 lore raw
Quoted 29 lines · Junio C Hamano
Quoted 14 lines · Junio C Hamano
Quoted 12 lines · Stefan Beller

As 'var' contains the whole value we get error messages that repeat the section and key currently:

warning: Invalid parameter 'true' for config option 'submodule.submodule.plugins/hooks.ignore.ignore'

Fix this by only giving the section name in the warning.

---
 submodule-config.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines

submodule-config.c static int parse_config(const char *var, const char *value, void *data) · line 336

Quoted 10 lines
submodule-config.c +1 -1
index 93453909cf..bb069bc097 100644
@@ -333,7 +333,7 @@ static int parse_config(const char *var, const char *value, void *data)
                      strcmp(value, "all") &&
                      strcmp(value, "none"))
                     warning("Invalid parameter '%s' for config option "
-                                    "'submodule.%s.ignore'", value, var);
+                                    "'submodule.%s.ignore'", value, name.buf);

Obviously correct.

Quoted 4 lines

But isn't this even more obviously correct?

        warning("invalid parameter '%s' for option %s", value, var);

Yes. I considered this when writing the patch. It is also obviously correct. The difference is whether you relay funny capitalization to the error message, which I thought we might not want to do?

git grep warning yields e.g.

diff.c:                 warning(_("Unknown value for 'diff.submodule'
config variable: '%s'"),
diff.c:                 warning(_("Found errors in 'diff.dirstat'

config variable:\n%s"),

So I conclude that we want to present normalized capitalization for config options
for error messages.

Thanks,
Stefan