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

[PATCH] add, merge, diff: do not use strcasecmp to compare config variable names

From
Jonathan Nieder <jrnieder@gmail.com>
Date
May 14, 2011, 20:19 UTC
Message-ID
<20110514201921.GA10758@elie>
In-Reply-To
<BANLkTi=MSfRhUhY1jkRC0agQNp7WHDG9FQ@mail.gmail.com>

The config machinery already makes section and variable names lowercase when parsing them, so using strcasecmp for comparison just feels wasteful. No noticeable change intended.

Noticed-by: Jay Soffian <jaysoffian@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Jay Soffian wrote:
> On Sat, May 14, 2011 at 3:01 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
>> No need to use strcasecmp --- the vars passed to config functions
>> already have the section and variable names in lowercase.
>
> Okay, it was a cut-and-paste from ignore-errors I think.
Good catch.
 builtin/add.c     |    4 ++--
 merge-recursive.c |    6 +++---
 xdiff-interface.c |    2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/builtin/add.c b/builtin/add.c
index 704141f..e57abdd 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -331,8 +331,8 @@ static struct option builtin_add_options[] = {
 
 static int add_config(const char *var, const char *value, void *cb)
 {
-	if (!strcasecmp(var, "add.ignoreerrors") ||
-	    !strcasecmp(var, "add.ignore-errors")) {
+	if (!strcmp(var, "add.ignoreerrors") ||
+	    !strcmp(var, "add.ignore-errors")) {
 		ignore_add_errors = git_config_bool(var, value);
 		return 0;
 	}
diff --git a/merge-recursive.c b/merge-recursive.c
index ecb1806..07ad1a3 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -1721,15 +1721,15 @@ int merge_recursive_generic(struct merge_options *o,
 static int merge_recursive_config(const char *var, const char *value, void *cb)
 {
 	struct merge_options *o = cb;
-	if (!strcasecmp(var, "merge.verbosity")) {
+	if (!strcmp(var, "merge.verbosity")) {
 		o->verbosity = git_config_int(var, value);
 		return 0;
 	}
-	if (!strcasecmp(var, "diff.renamelimit")) {
+	if (!strcmp(var, "diff.renamelimit")) {
 		o->diff_rename_limit = git_config_int(var, value);
 		return 0;
 	}
-	if (!strcasecmp(var, "merge.renamelimit")) {
+	if (!strcmp(var, "merge.renamelimit")) {
 		o->merge_rename_limit = git_config_int(var, value);
 		return 0;
 	}
diff --git a/xdiff-interface.c b/xdiff-interface.c
index 164581f..0e2c169 100644
--- a/xdiff-interface.c
+++ b/xdiff-interface.c
@@ -347,7 +347,7 @@ int git_xmerge_style = -1;
 
 int git_xmerge_config(const char *var, const char *value, void *cb)
 {
-	if (!strcasecmp(var, "merge.conflictstyle")) {
+	if (!strcmp(var, "merge.conflictstyle")) {
 		if (!value)
 			die("'%s' is not a boolean", var);
 		if (!strcmp(value, "diff3"))
-- 
1.7.5.1
Previous: Jay SoffianNext: Junio C Hamano
Message 5 of 22 in “Add log.abbrev-commit config option”
  1. Add log.abbrev-commit config optionJay Soffian, May 14, 2011
  2. Jay SoffianMay 14, 2011
  3. Jonathan NiederMay 14, 2011
  4. Jay SoffianMay 14, 2011
  5. add, merge, diff: do not use strcasecmp to compare config variable namesJonathan Nieder, May 14, 2011
  6. Junio C HamanoMay 15, 2011
  7. Add log.abbrevCommit config variableJay Soffian, May 14, 2011
  8. Jonathan NiederMay 14, 2011
  9. Jay SoffianMay 14, 2011
  10. Add log.abbrevCommit config variableJay Soffian, May 14, 2011
  11. Jay SoffianMay 15, 2011
  12. Junio C HamanoMay 15, 2011
  13. Jay SoffianMay 16, 2011
  14. Jonathan NiederMay 16, 2011
  15. Jay SoffianMay 16, 2011
  16. Junio C HamanoMay 17, 2011
  17. Junio C HamanoMay 17, 2011
  18. Jay SoffianMay 18, 2011
  19. Junio C HamanoMay 17, 2011
  20. Jay SoffianMay 17, 2011
  21. Junio C HamanoMay 15, 2011
  22. Michael J GruberMay 16, 2011

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.