use strpbrk(3) to search for characters from a given set
[git/debian.git] / t / t5408-send-pack-stdin.sh
blobe8737df6f95cde09b97bddba1425253039e58dbc
1 #!/bin/sh
3 test_description='send-pack --stdin tests'
4 . ./test-lib.sh
6 create_ref () {
7 tree=$(git write-tree) &&
8 test_tick &&
9 commit=$(echo "$1" | git commit-tree $tree) &&
10 git update-ref "$1" $commit
13 clear_remote () {
14 rm -rf remote.git &&
15 git init --bare remote.git
18 verify_push () {
19 git rev-parse "$1" >expect &&
20 git --git-dir=remote.git rev-parse "${2:-$1}" >actual &&
21 test_cmp expect actual
24 test_expect_success 'setup refs' '
25 cat >refs <<-\EOF &&
26 refs/heads/A
27 refs/heads/C
28 refs/tags/D
29 refs/heads/B
30 refs/tags/E
31 EOF
32 for i in $(cat refs); do
33 create_ref $i || return 1
34 done
37 # sanity check our setup
38 test_expect_success 'refs on cmdline' '
39 clear_remote &&
40 git send-pack remote.git $(cat refs) &&
41 for i in $(cat refs); do
42 verify_push $i || return 1
43 done
46 test_expect_success 'refs over stdin' '
47 clear_remote &&
48 git send-pack remote.git --stdin <refs &&
49 for i in $(cat refs); do
50 verify_push $i || return 1
51 done
54 test_expect_success 'stdin lines are full refspecs' '
55 clear_remote &&
56 echo "A:other" >input &&
57 git send-pack remote.git --stdin <input &&
58 verify_push refs/heads/A refs/heads/other
61 test_expect_success 'stdin mixed with cmdline' '
62 clear_remote &&
63 echo A >input &&
64 git send-pack remote.git --stdin B <input &&
65 verify_push A &&
66 verify_push B
69 test_expect_success 'cmdline refs written in order' '
70 clear_remote &&
71 test_must_fail git send-pack remote.git A:foo B:foo &&
72 verify_push A foo
75 test_expect_success '--stdin refs come after cmdline' '
76 clear_remote &&
77 echo A:foo >input &&
78 test_must_fail git send-pack remote.git --stdin B:foo <input &&
79 verify_push B foo
82 test_expect_success 'refspecs and --mirror do not mix (cmdline)' '
83 clear_remote &&
84 test_must_fail git send-pack remote.git --mirror $(cat refs)
87 test_expect_success 'refspecs and --mirror do not mix (stdin)' '
88 clear_remote &&
89 test_must_fail git send-pack remote.git --mirror --stdin <refs
92 test_done