summaryrefslogtreecommitdiff
path: root/builtin/remote.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2020-10-27 15:09:49 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2020-10-27 15:09:50 -0700
commit40696c67274305d6258539de5a36649cf833f712 (patch)
treec7f286e661d93790c42b5443cd4b0ab9dd9c6e4e /builtin/remote.c
parentMerge branch 'sk/force-if-includes' (diff)
parentclone: allow configurable default for `-o`/`--origin` (diff)
downloadtgif-40696c67274305d6258539de5a36649cf833f712.tar.xz
Merge branch 'sb/clone-origin'
"git clone" learned clone.defaultremotename configuration variable to customize what nickname to use to call the remote the repository was cloned from. * sb/clone-origin: clone: allow configurable default for `-o`/`--origin` clone: read new remote name from remote_name instead of option_origin clone: validate --origin option before use refs: consolidate remote name validation remote: add tests for add and rename with invalid names clone: use more conventional config/option layering clone: add tests for --template and some disallowed option pairs
Diffstat (limited to 'builtin/remote.c')
-rw-r--r--builtin/remote.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/builtin/remote.c b/builtin/remote.c
index 64b4b551eb..63f2b46c3d 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -194,8 +194,7 @@ static int add(int argc, const char **argv)
if (remote_is_configured(remote, 1))
die(_("remote %s already exists."), name);
- strbuf_addf(&buf2, "refs/heads/test:refs/remotes/%s/test", name);
- if (!valid_fetch_refspec(buf2.buf))
+ if (!valid_remote_name(name))
die(_("'%s' is not a valid remote name"), name);
strbuf_addf(&buf, "remote.%s.url", name);
@@ -696,11 +695,9 @@ static int mv(int argc, const char **argv)
if (remote_is_configured(newremote, 1))
die(_("remote %s already exists."), rename.new_name);
- strbuf_addf(&buf, "refs/heads/test:refs/remotes/%s/test", rename.new_name);
- if (!valid_fetch_refspec(buf.buf))
+ if (!valid_remote_name(rename.new_name))
die(_("'%s' is not a valid remote name"), rename.new_name);
- strbuf_reset(&buf);
strbuf_addf(&buf, "remote.%s", rename.old_name);
strbuf_addf(&buf2, "remote.%s", rename.new_name);
if (git_config_rename_section(buf.buf, buf2.buf) < 1)