Merge branch 'jk/maint-config-alias-fix'
authorJunio C Hamano <gitster@pobox.com>
Tue, 31 May 2011 03:19:14 +0000 (20:19 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 31 May 2011 03:19:14 +0000 (20:19 -0700)
* jk/maint-config-alias-fix:
handle_options(): do not miscount how many arguments were used
config: always parse GIT_CONFIG_PARAMETERS during git_config
git_config: don't peek at global config_parameters
config: make environment parsing routines static

Conflicts:
config.c

1  2 
cache.h
config.c
git.c
t/t1300-repo-config.sh
diff --cc cache.h
Simple merge
diff --cc config.c
index 9d368488893687a7b6986b5ab8eb1154f3ad7df9,8220c0cbf70bccf67659220908ba7046e13d50fe..a8267e926581378e46b83bd11ab38eac76886430
+++ b/config.c
@@@ -882,11 -835,20 +859,18 @@@ int git_config_early(config_fn_t fn, vo
                found += 1;
        }
  
-       ret += git_config_from_parameters(fn, data);
-       if (config_parameters)
-               found += 1;
+       switch (git_config_from_parameters(fn, data)) {
+       case -1: /* error */
+               ret--;
+               break;
+       case 0: /* found nothing */
+               break;
+       default: /* found at least one item */
+               found++;
+               break;
+       }
  
 -      if (found == 0)
 -              return -1;
 -      return ret;
 +      return ret == 0 ? found : ret;
  }
  
  int git_config(config_fn_t fn, void *data)
diff --cc git.c
Simple merge
index 53fb8228cf18e2b58f3ea63e98a0220fa0fd39f2,de2a014d8fade18d8e8f666c502e584a57473d28..3db56267ee89e1b585a548f7bee13386e47395f4
@@@ -876,25 -847,18 +876,32 @@@ test_expect_success 'check split_cmdlin
        "
  
  test_expect_success 'git -c "key=value" support' '
 -      test "z$(git -c name=value config name)" = zvalue &&
        test "z$(git -c core.name=value config core.name)" = zvalue &&
 -      test "z$(git -c CamelCase=value config camelcase)" = zvalue &&
 -      test "z$(git -c flag config --bool flag)" = ztrue &&
 -      test_must_fail git -c core.name=value config name
 +      test "z$(git -c foo.CamelCase=value config foo.camelcase)" = zvalue &&
 +      test "z$(git -c foo.flag config --bool foo.flag)" = ztrue &&
 +      test_must_fail git -c name=value config core.name
 +'
 +
 +test_expect_success 'key sanity-checking' '
 +      test_must_fail git config foo=bar &&
 +      test_must_fail git config foo=.bar &&
 +      test_must_fail git config foo.ba=r &&
 +      test_must_fail git config foo.1bar &&
 +      test_must_fail git config foo."ba
 +                              z".bar &&
 +      test_must_fail git config . false &&
 +      test_must_fail git config .foo false &&
 +      test_must_fail git config foo. false &&
 +      test_must_fail git config .foo. false &&
 +      git config foo.bar true &&
 +      git config foo."ba =z".bar false
  '
  
+ test_expect_success 'git -c works with aliases of builtins' '
+       git config alias.checkconfig "-c foo.check=bar config foo.check" &&
+       echo bar >expect &&
+       git checkconfig >actual &&
+       test_cmp expect actual
+ '
  test_done