Skip to content

Commit 444825c

Browse files
sjbaraggitster
authored andcommitted
remote: add tests for add and rename with invalid names
In preparation for a future patch that moves `builtin/remote.c`'s remote-name validation, ensure `git remote add` and `git remote rename` report errors when the new name isn't valid. Signed-off-by: Sean Barag <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 552955e commit 444825c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

t/t5505-remote.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,13 @@ test_expect_success 'rename errors out early when deleting non-existent branch'
179179
)
180180
'
181181

182+
test_expect_success 'rename errors out early when when new name is invalid' '
183+
test_config remote.foo.vcs bar &&
184+
echo "fatal: '\''invalid...name'\'' is not a valid remote name" >expect &&
185+
test_must_fail git remote rename foo invalid...name 2>actual &&
186+
test_i18ncmp expect actual
187+
'
188+
182189
test_expect_success 'add existing foreign_vcs remote' '
183190
test_config remote.foo.vcs bar &&
184191
echo "fatal: remote foo already exists." >expect &&
@@ -194,6 +201,12 @@ test_expect_success 'add existing foreign_vcs remote' '
194201
test_i18ncmp expect actual
195202
'
196203

204+
test_expect_success 'add invalid foreign_vcs remote' '
205+
echo "fatal: '\''invalid...name'\'' is not a valid remote name" >expect &&
206+
test_must_fail git remote add invalid...name bar 2>actual &&
207+
test_i18ncmp expect actual
208+
'
209+
197210
cat >test/expect <<EOF
198211
* remote origin
199212
Fetch URL: $(pwd)/one

0 commit comments

Comments
 (0)