462
test_must_fail git config inval.2key blabla
463
'
464
465
+test_expect_success 'set with 1 arg of "key=value": valid key suggests split form' '
466
+ test_must_fail git config set pull.rebase=false 2>err &&
467
+ test_grep "missing value to set to the variable .pull\\.rebase=false." err &&
468
+ test_grep "did you mean .git config set pull\\.rebase false." err
469
+'
470
+
471
+test_expect_success 'set with 1 arg of "key=value": implicit form suggests split form' '
472
+ test_must_fail git config pull.rebase=false 2>err &&
473
+ test_grep "missing value to set to the variable .pull\\.rebase=false." err &&
474
+ test_grep "did you mean .git config set pull\\.rebase false." err
475
+'
476
+
477
+test_expect_success 'set with 1 arg of "key=value": invalid key does not suggest split form' '
478
+ test_must_fail git config set foo=bar 2>err &&
479
+ test_grep "missing value to set to a variable with an invalid name .foo=bar." err &&
480
+ test_grep ! "did you mean" err
481
+'
482
+
483
+test_expect_success 'set with 1 arg: variable name starting with digit is invalid' '
484
+ test_must_fail git config set foo.1bar=baz 2>err &&
485
+ test_grep "missing value to set to a variable with an invalid name .foo\\.1bar=baz." err &&
486
+ test_grep ! "did you mean" err
487
+'
488
+
489
+test_expect_success 'set with 1 arg: digit-led section name is valid' '
490
+ test_must_fail git config set 1foo.bar=baz 2>err &&
491
+ test_grep "missing value to set to the variable .1foo\\.bar=baz." err &&
492
+ test_grep "did you mean .git config set 1foo\\.bar baz." err
493
+'
494
+
495
+test_expect_success 'set with 1 arg: subsection plus invalid variable name' '
496
+ test_must_fail git config set foo.some.b_r=baz 2>err &&
497
+ test_grep "missing value to set to a variable with an invalid name .foo\\.some\\.b_r=baz." err &&
498
+ test_grep ! "did you mean" err
499
+'
500
+
501
+test_expect_success 'set with 1 arg of valid key reports missing value' '
502
+ test_must_fail git config set pull.rebase 2>err &&
503
+ test_grep "missing value to set to the variable .pull\\.rebase." err &&
504
+ test_grep ! "did you mean" err
505
+'
506
+
507
+test_expect_success 'set with 2 args including "=" in invalid key does not suggest' '
508
+ test_must_fail git config set pull.rebase=false true 2>err &&
509
+ test_grep "invalid key: pull\\.rebase=false" err &&
510
+ test_grep ! "did you mean" err
511
+'
512
+
513
+test_expect_success '"=" inside subsection is valid' '
514
+ test_when_finished "rm -f subsection.cfg" &&
515
+ git config set -f subsection.cfg foo.bar=baz.boo qux &&
516
+ echo qux >expect &&
517
+ git config get -f subsection.cfg foo.bar=baz.boo >actual &&
518
+ test_cmp expect actual
519
+'
520
+
521
test_expect_success 'correct key' '
522
git config 123456.a123 987
523
'