]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5511-refspec.sh
Merge branch 'dl/checkout-p-merge-base'
[thirdparty/git.git] / t / t5511-refspec.sh
CommitLineData
46220ca1
JH
1#!/bin/sh
2
3test_description='refspec parsing'
4
5. ./test-lib.sh
6
7test_refspec () {
46220ca1
JH
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
24test_refspec push '' invalid
a83619d6
PB
25test_refspec push ':'
26test_refspec push '::' invalid
27test_refspec push '+:'
46220ca1
JH
28
29test_refspec fetch ''
30test_refspec fetch ':'
a83619d6 31test_refspec fetch '::' invalid
46220ca1
JH
32
33test_refspec push 'refs/heads/*:refs/remotes/frotz/*'
34test_refspec push 'refs/heads/*:refs/remotes/frotz' invalid
35test_refspec push 'refs/heads:refs/remotes/frotz/*' invalid
36test_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
47test_refspec fetch 'refs/heads/*:refs/remotes/frotz/*'
48test_refspec fetch 'refs/heads/*:refs/remotes/frotz' invalid
49test_refspec fetch 'refs/heads:refs/remotes/frotz/*' invalid
50test_refspec fetch 'refs/heads/master:refs/remotes/frotz/xyzzy'
51test_refspec fetch 'refs/heads/master::refs/remotes/frotz/xyzzy' invalid
52test_refspec fetch 'refs/heads/maste :refs/remotes/frotz/xyzzy' invalid
53
54test_refspec push 'master~1:refs/remotes/frotz/backup'
55test_refspec fetch 'master~1:refs/remotes/frotz/backup' invalid
56test_refspec push 'HEAD~4:refs/remotes/frotz/new'
57test_refspec fetch 'HEAD~4:refs/remotes/frotz/new' invalid
58
59test_refspec push 'HEAD'
60test_refspec fetch 'HEAD'
374fbaef
FC
61test_refspec push '@'
62test_refspec fetch '@'
46220ca1
JH
63test_refspec push 'refs/heads/ nitfol' invalid
64test_refspec fetch 'refs/heads/ nitfol' invalid
65
66test_refspec push 'HEAD:' invalid
67test_refspec fetch 'HEAD:'
68test_refspec push 'refs/heads/ nitfol:' invalid
69test_refspec fetch 'refs/heads/ nitfol:' invalid
70
71test_refspec push ':refs/remotes/frotz/deleteme'
72test_refspec fetch ':refs/remotes/frotz/HEAD-to-me'
73test_refspec push ':refs/remotes/frotz/delete me' invalid
74test_refspec fetch ':refs/remotes/frotz/HEAD to me' invalid
75
cd377f45
JK
76test_refspec fetch 'refs/heads/*/for-linus:refs/remotes/mine/*-blah'
77test_refspec push 'refs/heads/*/for-linus:refs/remotes/mine/*-blah'
abd2bde7 78
cd377f45
JK
79test_refspec fetch 'refs/heads*/for-linus:refs/remotes/mine/*'
80test_refspec push 'refs/heads*/for-linus:refs/remotes/mine/*'
abd2bde7
DB
81
82test_refspec fetch 'refs/heads/*/*/for-linus:refs/remotes/mine/*' invalid
83test_refspec push 'refs/heads/*/*/for-linus:refs/remotes/mine/*' invalid
84
cd377f45
JK
85test_refspec fetch 'refs/heads/*g*/for-linus:refs/remotes/mine/*' invalid
86test_refspec push 'refs/heads/*g*/for-linus:refs/remotes/mine/*' invalid
87
abd2bde7
DB
88test_refspec fetch 'refs/heads/*/for-linus:refs/remotes/mine/*'
89test_refspec push 'refs/heads/*/for-linus:refs/remotes/mine/*'
90
dde8a902
DT
91good=$(printf '\303\204')
92test_refspec fetch "refs/heads/${good}"
93bad=$(printf '\011tab')
94test_refspec fetch "refs/heads/${bad}" invalid
95
46220ca1 96test_done