aboutsummaryrefslogtreecommitdiff
path: root/t/t0014-alias.sh
diff options
context:
space:
mode:
Diffstat (limited to 't/t0014-alias.sh')
-rwxr-xr-xt/t0014-alias.sh85
1 files changed, 85 insertions, 0 deletions
diff --git a/t/t0014-alias.sh b/t/t0014-alias.sh
index 07a53e7366..68b4903cbf 100755
--- a/t/t0014-alias.sh
+++ b/t/t0014-alias.sh
@@ -112,4 +112,89 @@ test_expect_success 'cannot alias-shadow a sample of regular builtins' '
done
'
+test_expect_success 'alias without value reports error' '
+ test_when_finished "git config --unset alias.noval" &&
+ cat >>.git/config <<-\EOF &&
+ [alias]
+ noval
+ EOF
+ test_must_fail git noval 2>error &&
+ test_grep "alias.noval" error
+'
+
+test_expect_success 'subsection syntax works' '
+ test_config alias.testnew.command "!echo ran-subsection" &&
+ git testnew >output &&
+ test_grep "ran-subsection" output
+'
+
+test_expect_success 'subsection syntax only accepts command key' '
+ test_config alias.invalid.notcommand value &&
+ test_must_fail git invalid 2>error &&
+ test_grep -i "not a git command" error
+'
+
+test_expect_success 'subsection syntax requires value for command' '
+ test_when_finished "git config --remove-section alias.noval" &&
+ cat >>.git/config <<-\EOF &&
+ [alias "noval"]
+ command
+ EOF
+ test_must_fail git noval 2>error &&
+ test_grep "alias.noval.command" error
+'
+
+test_expect_success 'simple syntax is case-insensitive' '
+ test_config alias.LegacyCase "!echo ran-legacy" &&
+ git legacycase >output &&
+ test_grep "ran-legacy" output
+'
+
+test_expect_success 'subsection syntax is case-sensitive' '
+ test_config alias.SubCase.command "!echo ran-upper" &&
+ test_config alias.subcase.command "!echo ran-lower" &&
+ git SubCase >upper.out &&
+ git subcase >lower.out &&
+ test_grep "ran-upper" upper.out &&
+ test_grep "ran-lower" lower.out
+'
+
+test_expect_success 'UTF-8 alias with Swedish characters' '
+ test_config alias."förgrena".command "!echo ran-swedish" &&
+ git förgrena >output &&
+ test_grep "ran-swedish" output
+'
+
+test_expect_success 'UTF-8 alias with CJK characters' '
+ test_config alias."分支".command "!echo ran-cjk" &&
+ git 分支 >output &&
+ test_grep "ran-cjk" output
+'
+
+test_expect_success 'alias with spaces in name' '
+ test_config alias."test name".command "!echo ran-spaces" &&
+ git "test name" >output &&
+ test_grep "ran-spaces" output
+'
+
+test_expect_success 'subsection aliases listed in help -a' '
+ test_config alias."förgrena".command "!echo test" &&
+ git help -a >output &&
+ test_grep "förgrena" output
+'
+
+test_expect_success 'empty subsection treated as no subsection' '
+ test_config "alias..something" "!echo foobar" &&
+ git something >actual &&
+ echo foobar >expect &&
+ test_cmp expect actual
+'
+
+test_expect_success 'alias with leading dot via subsection syntax' '
+ test_config alias.".something".command "!echo foobar" &&
+ git .something >actual &&
+ echo foobar >expect &&
+ test_cmp expect actual
+'
+
test_done