Merge branch 'js/alias-case-sensitivity'
authorJunio C Hamano <gitster@pobox.com>
Thu, 20 Jul 2017 23:29:59 +0000 (16:29 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 20 Jul 2017 23:29:59 +0000 (16:29 -0700)
A recent update broke an alias that contained an uppercase letter.

* js/alias-case-sensitivity:
alias: compare alias name *case-insensitively*
t1300: demonstrate that CamelCased aliases regressed

1  2 
alias.c
t/t1300-repo-config.sh
diff --combined alias.c
index 39f622e4141576b1170131f6c4b14316becb1a71,caa88e047c3ee1b9fbfdb7bf16bc9e5c74623a6f..bf146e526329309df360b9f1028ca2f767743efa
+++ b/alias.c
@@@ -1,5 -1,4 +1,5 @@@
  #include "cache.h"
 +#include "config.h"
  
  struct config_alias_data {
        const char *alias;
@@@ -11,7 -10,7 +11,7 @@@ static int config_alias_cb(const char *
        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;
@@@ -62,7 -61,8 +62,7 @@@ int split_cmdline(char *cmdline, const 
                                src++;
                                c = cmdline[src];
                                if (!c) {
 -                                      free(*argv);
 -                                      *argv = NULL;
 +                                      FREE_AND_NULL(*argv);
                                        return -SPLIT_CMDLINE_BAD_ENDING;
                                }
                        }
@@@ -74,7 -74,8 +74,7 @@@
        cmdline[dst] = 0;
  
        if (quoted) {
 -              free(*argv);
 -              *argv = NULL;
 +              FREE_AND_NULL(*argv);
                return -SPLIT_CMDLINE_UNCLOSED_QUOTE;
        }
  
diff --combined t/t1300-repo-config.sh
index a37ef0422212eafdae4b4c0fae9e28d4a183117f,23312bee286ab89e24196b150d99bb3283d5d094..364a537000bbbdd43047bd3f9c52c950a96dcbda
@@@ -1075,6 -1075,13 +1075,13 @@@ test_expect_success 'git -c works with 
        test_cmp expect actual
  '
  
+ test_expect_success '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 &&
@@@ -1545,10 -1552,4 +1552,10 @@@ test_expect_success !MINGW '--show-orig
        test_cmp expect output
  '
  
 +test_expect_success '--local requires a repo' '
 +      # we expect 128 to ensure that we do not simply
 +      # fail to find anything and return code "1"
 +      test_expect_code 128 nongit git config --local foo.bar
 +'
 +
  test_done