Junio C Hamano | 46220ca | 2008-03-20 23:34:37 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='refspec parsing' |
| 4 | |
| 5 | . ./test-lib.sh |
| 6 | |
| 7 | test_refspec () { |
Junio C Hamano | 46220ca | 2008-03-20 23:34:37 -0700 | [diff] [blame] | 8 | kind=$1 refspec=$2 expect=$3 |
| 9 | git config remote.frotz.url "." && |
| 10 | git config --remove-section remote.frotz && |
| 11 | git config remote.frotz.url "." && |
| 12 | git config "remote.frotz.$kind" "$refspec" && |
| 13 | if test "$expect" != invalid |
| 14 | then |
| 15 | title="$kind $refspec" |
| 16 | test='git ls-remote frotz' |
| 17 | else |
| 18 | title="$kind $refspec (invalid)" |
| 19 | test='test_must_fail git ls-remote frotz' |
| 20 | fi |
| 21 | test_expect_success "$title" "$test" |
| 22 | } |
| 23 | |
| 24 | test_refspec push '' invalid |
Paolo Bonzini | a83619d | 2008-04-28 11:32:12 -0400 | [diff] [blame] | 25 | test_refspec push ':' |
| 26 | test_refspec push '::' invalid |
| 27 | test_refspec push '+:' |
Junio C Hamano | 46220ca | 2008-03-20 23:34:37 -0700 | [diff] [blame] | 28 | |
| 29 | test_refspec fetch '' |
| 30 | test_refspec fetch ':' |
Paolo Bonzini | a83619d | 2008-04-28 11:32:12 -0400 | [diff] [blame] | 31 | test_refspec fetch '::' invalid |
Junio C Hamano | 46220ca | 2008-03-20 23:34:37 -0700 | [diff] [blame] | 32 | |
| 33 | test_refspec push 'refs/heads/*:refs/remotes/frotz/*' |
| 34 | test_refspec push 'refs/heads/*:refs/remotes/frotz' invalid |
| 35 | test_refspec push 'refs/heads:refs/remotes/frotz/*' invalid |
| 36 | test_refspec push 'refs/heads/master:refs/remotes/frotz/xyzzy' |
| 37 | |
| 38 | |
| 39 | # These have invalid LHS, but we do not have a formal "valid sha-1 |
| 40 | # expression syntax checker" so they are not checked with the current |
| 41 | # code. They will be caught downstream anyway, but we may want to |
| 42 | # have tighter check later... |
| 43 | |
| 44 | : test_refspec push 'refs/heads/master::refs/remotes/frotz/xyzzy' invalid |
| 45 | : test_refspec push 'refs/heads/maste :refs/remotes/frotz/xyzzy' invalid |
| 46 | |
| 47 | test_refspec fetch 'refs/heads/*:refs/remotes/frotz/*' |
| 48 | test_refspec fetch 'refs/heads/*:refs/remotes/frotz' invalid |
| 49 | test_refspec fetch 'refs/heads:refs/remotes/frotz/*' invalid |
| 50 | test_refspec fetch 'refs/heads/master:refs/remotes/frotz/xyzzy' |
| 51 | test_refspec fetch 'refs/heads/master::refs/remotes/frotz/xyzzy' invalid |
| 52 | test_refspec fetch 'refs/heads/maste :refs/remotes/frotz/xyzzy' invalid |
| 53 | |
| 54 | test_refspec push 'master~1:refs/remotes/frotz/backup' |
| 55 | test_refspec fetch 'master~1:refs/remotes/frotz/backup' invalid |
| 56 | test_refspec push 'HEAD~4:refs/remotes/frotz/new' |
| 57 | test_refspec fetch 'HEAD~4:refs/remotes/frotz/new' invalid |
| 58 | |
| 59 | test_refspec push 'HEAD' |
| 60 | test_refspec fetch 'HEAD' |
| 61 | test_refspec push 'refs/heads/ nitfol' invalid |
| 62 | test_refspec fetch 'refs/heads/ nitfol' invalid |
| 63 | |
| 64 | test_refspec push 'HEAD:' invalid |
| 65 | test_refspec fetch 'HEAD:' |
| 66 | test_refspec push 'refs/heads/ nitfol:' invalid |
| 67 | test_refspec fetch 'refs/heads/ nitfol:' invalid |
| 68 | |
| 69 | test_refspec push ':refs/remotes/frotz/deleteme' |
| 70 | test_refspec fetch ':refs/remotes/frotz/HEAD-to-me' |
| 71 | test_refspec push ':refs/remotes/frotz/delete me' invalid |
| 72 | test_refspec fetch ':refs/remotes/frotz/HEAD to me' invalid |
| 73 | |
Jacob Keller | cd377f4 | 2015-07-22 14:05:33 -0700 | [diff] [blame] | 74 | test_refspec fetch 'refs/heads/*/for-linus:refs/remotes/mine/*-blah' |
| 75 | test_refspec push 'refs/heads/*/for-linus:refs/remotes/mine/*-blah' |
Daniel Barkalow | abd2bde | 2009-03-07 01:11:39 -0500 | [diff] [blame] | 76 | |
Jacob Keller | cd377f4 | 2015-07-22 14:05:33 -0700 | [diff] [blame] | 77 | test_refspec fetch 'refs/heads*/for-linus:refs/remotes/mine/*' |
| 78 | test_refspec push 'refs/heads*/for-linus:refs/remotes/mine/*' |
Daniel Barkalow | abd2bde | 2009-03-07 01:11:39 -0500 | [diff] [blame] | 79 | |
| 80 | test_refspec fetch 'refs/heads/*/*/for-linus:refs/remotes/mine/*' invalid |
| 81 | test_refspec push 'refs/heads/*/*/for-linus:refs/remotes/mine/*' invalid |
| 82 | |
Jacob Keller | cd377f4 | 2015-07-22 14:05:33 -0700 | [diff] [blame] | 83 | test_refspec fetch 'refs/heads/*g*/for-linus:refs/remotes/mine/*' invalid |
| 84 | test_refspec push 'refs/heads/*g*/for-linus:refs/remotes/mine/*' invalid |
| 85 | |
Daniel Barkalow | abd2bde | 2009-03-07 01:11:39 -0500 | [diff] [blame] | 86 | test_refspec fetch 'refs/heads/*/for-linus:refs/remotes/mine/*' |
| 87 | test_refspec push 'refs/heads/*/for-linus:refs/remotes/mine/*' |
| 88 | |
David Turner | dde8a90 | 2014-06-03 23:38:10 -0400 | [diff] [blame] | 89 | good=$(printf '\303\204') |
| 90 | test_refspec fetch "refs/heads/${good}" |
| 91 | bad=$(printf '\011tab') |
| 92 | test_refspec fetch "refs/heads/${bad}" invalid |
| 93 | |
Junio C Hamano | 46220ca | 2008-03-20 23:34:37 -0700 | [diff] [blame] | 94 | test_done |