Merge branch 'kz/merge-fail-early-upon-refresh-failure'
[git.git] / t / t5511-refspec.sh
blobfc55681a3f2cb5f1b27e6b939142e4c7693e043b
1 #!/bin/sh
3 test_description='refspec parsing'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 test_refspec () {
9 kind=$1 refspec=$2 expect=$3
10 git config remote.frotz.url "." &&
11 git config --remove-section remote.frotz &&
12 git config remote.frotz.url "." &&
13 git config "remote.frotz.$kind" "$refspec" &&
14 if test "$expect" != invalid
15 then
16 title="$kind $refspec"
17 test='git ls-remote frotz'
18 else
19 title="$kind $refspec (invalid)"
20 test='test_must_fail git ls-remote frotz'
22 test_expect_success "$title" "$test"
25 test_refspec push '' invalid
26 test_refspec push ':'
27 test_refspec push '::' invalid
28 test_refspec push '+:'
30 test_refspec fetch ''
31 test_refspec fetch ':'
32 test_refspec fetch '::' invalid
34 test_refspec push 'refs/heads/*:refs/remotes/frotz/*'
35 test_refspec push 'refs/heads/*:refs/remotes/frotz' invalid
36 test_refspec push 'refs/heads:refs/remotes/frotz/*' invalid
37 test_refspec push 'refs/heads/main:refs/remotes/frotz/xyzzy'
40 # These have invalid LHS, but we do not have a formal "valid sha-1
41 # expression syntax checker" so they are not checked with the current
42 # code. They will be caught downstream anyway, but we may want to
43 # have tighter check later...
45 : test_refspec push 'refs/heads/main::refs/remotes/frotz/xyzzy' invalid
46 : test_refspec push 'refs/heads/maste :refs/remotes/frotz/xyzzy' invalid
48 test_refspec fetch 'refs/heads/*:refs/remotes/frotz/*'
49 test_refspec fetch 'refs/heads/*:refs/remotes/frotz' invalid
50 test_refspec fetch 'refs/heads:refs/remotes/frotz/*' invalid
51 test_refspec fetch 'refs/heads/main:refs/remotes/frotz/xyzzy'
52 test_refspec fetch 'refs/heads/main::refs/remotes/frotz/xyzzy' invalid
53 test_refspec fetch 'refs/heads/maste :refs/remotes/frotz/xyzzy' invalid
55 test_refspec push 'main~1:refs/remotes/frotz/backup'
56 test_refspec fetch 'main~1:refs/remotes/frotz/backup' invalid
57 test_refspec push 'HEAD~4:refs/remotes/frotz/new'
58 test_refspec fetch 'HEAD~4:refs/remotes/frotz/new' invalid
60 test_refspec push 'HEAD'
61 test_refspec fetch 'HEAD'
62 test_refspec push '@'
63 test_refspec fetch '@'
64 test_refspec push 'refs/heads/ nitfol' invalid
65 test_refspec fetch 'refs/heads/ nitfol' invalid
67 test_refspec push 'HEAD:' invalid
68 test_refspec fetch 'HEAD:'
69 test_refspec push 'refs/heads/ nitfol:' invalid
70 test_refspec fetch 'refs/heads/ nitfol:' invalid
72 test_refspec push ':refs/remotes/frotz/deleteme'
73 test_refspec fetch ':refs/remotes/frotz/HEAD-to-me'
74 test_refspec push ':refs/remotes/frotz/delete me' invalid
75 test_refspec fetch ':refs/remotes/frotz/HEAD to me' invalid
77 test_refspec fetch 'refs/heads/*/for-linus:refs/remotes/mine/*-blah'
78 test_refspec push 'refs/heads/*/for-linus:refs/remotes/mine/*-blah'
80 test_refspec fetch 'refs/heads*/for-linus:refs/remotes/mine/*'
81 test_refspec push 'refs/heads*/for-linus:refs/remotes/mine/*'
83 test_refspec fetch 'refs/heads/*/*/for-linus:refs/remotes/mine/*' invalid
84 test_refspec push 'refs/heads/*/*/for-linus:refs/remotes/mine/*' invalid
86 test_refspec fetch 'refs/heads/*g*/for-linus:refs/remotes/mine/*' invalid
87 test_refspec push 'refs/heads/*g*/for-linus:refs/remotes/mine/*' invalid
89 test_refspec fetch 'refs/heads/*/for-linus:refs/remotes/mine/*'
90 test_refspec push 'refs/heads/*/for-linus:refs/remotes/mine/*'
92 good=$(printf '\303\204')
93 test_refspec fetch "refs/heads/${good}"
94 bad=$(printf '\011tab')
95 test_refspec fetch "refs/heads/${bad}" invalid
97 test_done