summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/remote.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/remote.c b/src/remote.c
index d58927f28..99b5bacc0 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -97,6 +97,7 @@ static int write_add_refspec(git_repository *repo, const char *name, const char
{
git_config *cfg;
git_buf var = GIT_BUF_INIT;
+ git_refspec spec;
const char *fmt;
int error;
@@ -108,6 +109,15 @@ static int write_add_refspec(git_repository *repo, const char *name, const char
if ((error = ensure_remote_name_is_valid(name)) < 0)
return error;
+ if ((error = git_refspec__parse(&spec, refspec, fetch)) < 0) {
+ if (giterr_last()->klass != GITERR_NOMEMORY)
+ error = GIT_EINVALIDSPEC;
+
+ return error;
+ }
+
+ git_refspec__free(&spec);
+
if ((error = git_buf_printf(&var, fmt, name)) < 0)
return error;