From 084b04409312e8d95aa51edb04dde7ff56f66fba Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 14 Jul 2017 10:39:29 +0200 Subject: [PATCH 1/2] t1300: demonstrate that CamelCased aliases regressed It is totally legitimate to add CamelCased aliases, but due to the way config keys are compared, the case does not matter. Except that now it does: the alias name is expected to be all lower-case. This is a regression introduced by a9bcf6586d1 (alias: use the early config machinery to expand aliases, 2017-06-14). Noticed by Alejandro Pauly, diagnosed by Kevin Willford. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t1300-repo-config.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh index f664bfc671..f22b611680 100755 --- a/t/t1300-repo-config.sh +++ b/t/t1300-repo-config.sh @@ -1075,6 +1075,13 @@ test_expect_success 'git -c works with aliases of builtins' ' test_cmp expect actual ' +test_expect_failure 'aliases can be CamelCased' ' + test_config alias.CamelCased "rev-parse HEAD" && + git CamelCased >out && + git rev-parse HEAD >expect && + test_cmp expect out +' + test_expect_success 'git -c does not split values on equals' ' echo "value with = in it" >expect && git -c core.foo="value with = in it" config core.foo >actual && From 643df7e234dda47a4748311361a82df5415b7bc1 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 14 Jul 2017 10:39:38 +0200 Subject: [PATCH 2/2] alias: compare alias name *case-insensitively* 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 Signed-off-by: Junio C Hamano --- 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 0526304661..caa88e047c 100644 --- a/alias.c +++ b/alias.c @@ -10,7 +10,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 f22b611680..23312bee28 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 &&