Merge branch 'cl/config-regexp-docfix' into maint-2.46
[git/gitster.git] / t / t0014-alias.sh
blob854d59ec58c25ab2cfb58113bf5ea8d670829fe0
1 #!/bin/sh
3 test_description='git command aliasing'
5 . ./test-lib.sh
7 test_expect_success 'nested aliases - internal execution' '
8 git config alias.nested-internal-1 nested-internal-2 &&
9 git config alias.nested-internal-2 status &&
10 git nested-internal-1 >output &&
11 test_grep "^On branch " output
14 test_expect_success 'nested aliases - mixed execution' '
15 git config alias.nested-external-1 nested-external-2 &&
16 git config alias.nested-external-2 "!git nested-external-3" &&
17 git config alias.nested-external-3 status &&
18 git nested-external-1 >output &&
19 test_grep "^On branch " output
22 test_expect_success 'looping aliases - internal execution' '
23 git config alias.loop-internal-1 loop-internal-2 &&
24 git config alias.loop-internal-2 loop-internal-3 &&
25 git config alias.loop-internal-3 loop-internal-2 &&
26 test_must_fail git loop-internal-1 2>output &&
27 test_grep "^fatal: alias loop detected: expansion of" output
30 # This test is disabled until external loops are fixed, because would block
31 # the test suite for a full minute.
33 #test_expect_failure 'looping aliases - mixed execution' '
34 # git config alias.loop-mixed-1 loop-mixed-2 &&
35 # git config alias.loop-mixed-2 "!git loop-mixed-1" &&
36 # test_must_fail git loop-mixed-1 2>output &&
37 # test_grep "^fatal: alias loop detected: expansion of" output
40 test_expect_success 'run-command formats empty args properly' '
41 test_must_fail env GIT_TRACE=1 git frotz a "" b " " c 2>actual.raw &&
42 sed -ne "/run_command:/s/.*trace: run_command: //p" actual.raw >actual &&
43 echo "git-frotz a '\'''\'' b '\'' '\'' c" >expect &&
44 test_cmp expect actual
47 test_expect_success 'tracing a shell alias with arguments shows trace of prepared command' '
48 cat >expect <<-EOF &&
49 trace: start_command: SHELL -c ${SQ}echo \$* "\$@"${SQ} ${SQ}echo \$*${SQ} arg
50 EOF
51 git config alias.echo "!echo \$*" &&
52 env GIT_TRACE=1 git echo arg 2>output &&
53 # redact platform differences
54 sed -n -e "s/^\(trace: start_command:\) .* -c /\1 SHELL -c /p" output >actual &&
55 test_cmp expect actual
58 test_done