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