The eleventh batch
[git/gitster.git] / t / t5408-send-pack-stdin.sh
blobc3695a4d4e3bbf43b815206f9334327868b7d149
1 #!/bin/sh
3 test_description='send-pack --stdin tests'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 create_ref () {
9 tree=$(git write-tree) &&
10 test_tick &&
11 commit=$(echo "$1" | git commit-tree $tree) &&
12 git update-ref "$1" $commit
15 clear_remote () {
16 rm -rf remote.git &&
17 git init --bare remote.git
20 verify_push () {
21 git rev-parse "$1" >expect &&
22 git --git-dir=remote.git rev-parse "${2:-$1}" >actual &&
23 test_cmp expect actual
26 test_expect_success 'setup refs' '
27 cat >refs <<-\EOF &&
28 refs/heads/A
29 refs/heads/C
30 refs/tags/D
31 refs/heads/B
32 refs/tags/E
33 EOF
34 for i in $(cat refs); do
35 create_ref $i || return 1
36 done
39 # sanity check our setup
40 test_expect_success 'refs on cmdline' '
41 clear_remote &&
42 git send-pack remote.git $(cat refs) &&
43 for i in $(cat refs); do
44 verify_push $i || return 1
45 done
48 test_expect_success 'refs over stdin' '
49 clear_remote &&
50 git send-pack remote.git --stdin <refs &&
51 for i in $(cat refs); do
52 verify_push $i || return 1
53 done
56 test_expect_success 'stdin lines are full refspecs' '
57 clear_remote &&
58 echo "A:other" >input &&
59 git send-pack remote.git --stdin <input &&
60 verify_push refs/heads/A refs/heads/other
63 test_expect_success 'stdin mixed with cmdline' '
64 clear_remote &&
65 echo A >input &&
66 git send-pack remote.git --stdin B <input &&
67 verify_push A &&
68 verify_push B
71 test_expect_success 'cmdline refs written in order' '
72 clear_remote &&
73 test_must_fail git send-pack remote.git A:foo B:foo &&
74 verify_push A foo
77 test_expect_success '--stdin refs come after cmdline' '
78 clear_remote &&
79 echo A:foo >input &&
80 test_must_fail git send-pack remote.git --stdin B:foo <input &&
81 verify_push B foo
84 test_expect_success 'refspecs and --mirror do not mix (cmdline)' '
85 clear_remote &&
86 test_must_fail git send-pack remote.git --mirror $(cat refs)
89 test_expect_success 'refspecs and --mirror do not mix (stdin)' '
90 clear_remote &&
91 test_must_fail git send-pack remote.git --mirror --stdin <refs
94 test_done