blob: cfc71c3bd4318758570f0aa7206d63fa71fedb4e [file] [log] [blame]
Jeff King32696a42022-09-28 18:50:36 -04001#!/bin/sh
2
3test_description='git shell tests'
4. ./test-lib.sh
5
6test_expect_success 'shell allows upload-pack' '
7 printf 0000 >input &&
8 git upload-pack . <input >expect &&
9 git shell -c "git-upload-pack $SQ.$SQ" <input >actual &&
10 test_cmp expect actual
11'
12
13test_expect_success 'shell forbids other commands' '
14 test_must_fail git shell -c "git config foo.bar baz"
15'
16
17test_expect_success 'shell forbids interactive use by default' '
18 test_must_fail git shell
19'
20
21test_expect_success 'shell allows interactive command' '
22 mkdir git-shell-commands &&
23 write_script git-shell-commands/ping <<-\EOF &&
24 echo pong
25 EOF
26 echo pong >expect &&
27 echo ping | git shell >actual &&
28 test_cmp expect actual
29'
30
Jeff King71ad7fe2022-09-28 18:52:48 -040031test_expect_success 'shell complains of overlong commands' '
32 perl -e "print \"a\" x 2**12 for (0..2**19)" |
33 test_must_fail git shell 2>err &&
34 grep "too long" err
35'
36
Jeff King32696a42022-09-28 18:50:36 -040037test_done