aboutsummaryrefslogtreecommitdiff
path: root/t/t5511-refspec.sh
blob: f541f30bc2f8745dad051bc10a0989be1f2b3ff0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/sh

test_description='refspec parsing'

. ./test-lib.sh

test_refspec () {
	kind=$1 refspec=$2 expect=$3
	git config remote.frotz.url "." &&
	git config --remove-section remote.frotz &&
	git config remote.frotz.url "." &&
	git config "remote.frotz.$kind" "$refspec" &&
	if test "$expect" != invalid
	then
		title="$kind $refspec"
		test='git ls-remote frotz'
	else
		title="$kind $refspec (invalid)"
		test='test_must_fail git ls-remote frotz'
	fi
	test_expect_success "$title" "$test"
}

test_refspec push ''						invalid
test_refspec push ':'
test_refspec push '::'						invalid
test_refspec push '+:'

test_refspec fetch ''
test_refspec fetch ':'
test_refspec fetch '::'						invalid

test_refspec push 'refs/heads/*:refs/remotes/frotz/*'
test_refspec push 'refs/heads/*:refs/remotes/frotz'		invalid
test_refspec push 'refs/heads:refs/remotes/frotz/*'		invalid
test_refspec push 'refs/heads/master:refs/remotes/frotz/xyzzy'


# These have invalid LHS, but we do not have a formal "valid sha-1
# expression syntax checker" so they are not checked with the current
# code.  They will be caught downstream anyway, but we may want to
# have tighter check later...

: test_refspec push 'refs/heads/master::refs/remotes/frotz/xyzzy'	invalid
: test_refspec push 'refs/heads/maste :refs/remotes/frotz/xyzzy'	invalid

test_refspec fetch 'refs/heads/*:refs/remotes/frotz/*'
test_refspec fetch 'refs/heads/*:refs/remotes/frotz'		invalid
test_refspec fetch 'refs/heads:refs/remotes/frotz/*'		invalid
test_refspec fetch 'refs/heads/master:refs/remotes/frotz/xyzzy'
test_refspec fetch 'refs/heads/master::refs/remotes/frotz/xyzzy'	invalid
test_refspec fetch 'refs/heads/maste :refs/remotes/frotz/xyzzy'	invalid

test_refspec push 'master~1:refs/remotes/frotz/backup'
test_refspec fetch 'master~1:refs/remotes/frotz/backup'		invalid
test_refspec push 'HEAD~4:refs/remotes/frotz/new'
test_refspec fetch 'HEAD~4:refs/remotes/frotz/new'		invalid

test_refspec push 'HEAD'
test_refspec fetch 'HEAD'
test_refspec push 'refs/heads/ nitfol'				invalid
test_refspec fetch 'refs/heads/ nitfol'				invalid

test_refspec push 'HEAD:'					invalid
test_refspec fetch 'HEAD:'
test_refspec push 'refs/heads/ nitfol:'				invalid
test_refspec fetch 'refs/heads/ nitfol:'			invalid

test_refspec push ':refs/remotes/frotz/deleteme'
test_refspec fetch ':refs/remotes/frotz/HEAD-to-me'
test_refspec push ':refs/remotes/frotz/delete me'		invalid
test_refspec fetch ':refs/remotes/frotz/HEAD to me'		invalid

test_refspec fetch 'refs/heads/*/for-linus:refs/remotes/mine/*-blah'
test_refspec push 'refs/heads/*/for-linus:refs/remotes/mine/*-blah'

test_refspec fetch 'refs/heads*/for-linus:refs/remotes/mine/*'
test_refspec push 'refs/heads*/for-linus:refs/remotes/mine/*'

test_refspec fetch 'refs/heads/*/*/for-linus:refs/remotes/mine/*' invalid
test_refspec push 'refs/heads/*/*/for-linus:refs/remotes/mine/*' invalid

test_refspec fetch 'refs/heads/*g*/for-linus:refs/remotes/mine/*' invalid
test_refspec push 'refs/heads/*g*/for-linus:refs/remotes/mine/*' invalid

test_refspec fetch 'refs/heads/*/for-linus:refs/remotes/mine/*'
test_refspec push 'refs/heads/*/for-linus:refs/remotes/mine/*'

good=$(printf '\303\204')
test_refspec fetch "refs/heads/${good}"
bad=$(printf '\011tab')
test_refspec fetch "refs/heads/${bad}"				invalid

test_done