alias_all_urls();
}
-/*
- * This function frees a refspec array.
- * Warning: code paths should be checked to ensure that the src
- * and dst pointers are always freeable pointers as well
- * as the refspec pointer itself.
- */
-static void free_refspecs(struct refspec *refspec, int nr_refspec)
-{
- int i;
-
- if (!refspec)
- return;
-
- for (i = 0; i < nr_refspec; i++) {
- free(refspec[i].src);
- free(refspec[i].dst);
- }
- free(refspec);
-}
-
static struct refspec *parse_refspec_internal(int nr_refspec, const char **refspec, int fetch, int verify)
{
int i;
* since it is only possible to reach this point from within
* the for loop above.
*/
- free_refspecs(rs, i+1);
+ free_refspec(i+1, rs);
return NULL;
}
die("Invalid refspec '%s'", refspec[i]);
struct refspec *refspec;
refspec = parse_refspec_internal(1, &fetch_refspec_str, 1, 1);
- free_refspecs(refspec, 1);
+ free_refspec(1, refspec);
return !!refspec;
}
void free_refspec(int nr_refspec, struct refspec *refspec)
{
int i;
+
+ if (!refspec)
+ return;
+
for (i = 0; i < nr_refspec; i++) {
free(refspec[i].src);
free(refspec[i].dst);
{
if (!name[0] || is_dot_or_dotdot(name))
return 0;
- return !strchr(name, '/'); /* no slash */
+
+ /* remote nicknames cannot contain slashes */
+ while (*name)
+ if (is_dir_sep(*name++))
+ return 0;
+ return 1;
}
const char *remote_for_branch(struct branch *branch, int *explicit)
else if (is_null_oid(&matched_src->new_oid))
error("unable to delete '%s': remote ref does not exist",
dst_value);
- else if ((dst_guess = guess_ref(dst_value, matched_src)))
+ else if ((dst_guess = guess_ref(dst_value, matched_src))) {
matched_dst = make_linked_ref(dst_guess, dst_tail);
- else
+ free(dst_guess);
+ } else
error("unable to push to unqualified destination: %s\n"
"The destination refspec neither matches an "
"existing ref on the remote nor\n"