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

[PATCH 2/2] alias: compare alias name *case-insensitively*

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jul 14, 2017, 08:39 UTC
Message-ID
<75bfe3653dd65e4219a78cea8e9308060a84af4f.1500021526.git.johannes.schindelin@gmx.de>
In-Reply-To
<cover.1500021526.git.johannes.schindelin@gmx.de>

It is totally legitimate to add CamelCased aliases, but due to the way config keys are compared, the case does not matter.

Therefore, we must compare the alias name insensitively to the config keys.

This fixes a regression introduced by a9bcf6586d1 (alias: use the early config machinery to expand aliases, 2017-06-14).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 alias.c                | 2 +-
 t/t1300-repo-config.sh | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/alias.c b/alias.c
index 39f622e4141..bf146e52632 100644
--- a/alias.c
+++ b/alias.c
@@ -11,7 +11,7 @@ static int config_alias_cb(const char *key, const char *value, void *d)
 	struct config_alias_data *data = d;
 	const char *p;
 
-	if (skip_prefix(key, "alias.", &p) && !strcmp(p, data->alias))
+	if (skip_prefix(key, "alias.", &p) && !strcasecmp(p, data->alias))
 		return git_config_string((const char **)&data->v, key, value);
 
 	return 0;
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
index 0df71b84ccf..364a537000b 100755
--- a/t/t1300-repo-config.sh
+++ b/t/t1300-repo-config.sh
@@ -1075,7 +1075,7 @@ test_expect_success 'git -c works with aliases of builtins' '
 	test_cmp expect actual
 '
 
-test_expect_failure 'aliases can be CamelCased' '
+test_expect_success 'aliases can be CamelCased' '
 	test_config alias.CamelCased "rev-parse HEAD" &&
 	git CamelCased >out &&
 	git rev-parse HEAD >expect &&
-- 
2.13.3.windows.1.13.gaf0c2223da0
Previous: Johannes SchindelinNext: Jeff King
Message 3 of 10 in “Fix regression: CamelCased aliases”
  1. 0/2 Fix regression: CamelCased aliasesJohannes Schindelin, Jul 14, 2017
  2. 1/2 t1300: demonstrate that CamelCased aliases regressedJohannes Schindelin, Jul 14, 2017
  3. 2/2 alias: compare alias name *case-insensitively*Johannes Schindelin, Jul 14, 2017
  4. Jeff KingJul 14, 2017
  5. Junio C HamanoJul 14, 2017
  6. Jeff KingJul 14, 2017
  7. Junio C HamanoJul 14, 2017
  8. astianJul 14, 2017
  9. Jeff KingJul 14, 2017
  10. Junio C HamanoJul 15, 2017

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.