From: Junio C Hamano Date: Tue, 13 Jun 2017 20:27:06 +0000 (-0700) Subject: Merge branch 'jk/drop-free-refspecs' into maint X-Git-Tag: v2.13.2~15 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/9451a7b629478790ad621d41b3f12ab8aa9097cc?ds=inline;hp=-c Merge branch 'jk/drop-free-refspecs' into maint Code clean-up. * jk/drop-free-refspecs: remote: drop free_refspecs() function --- 9451a7b629478790ad621d41b3f12ab8aa9097cc diff --combined remote.c index 32f137e966,fbb405660a..16eb39e06e --- a/remote.c +++ b/remote.c @@@ -477,26 -477,6 +477,6 @@@ static void read_config(void 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; @@@ -610,7 -590,7 +590,7 @@@ * 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]); @@@ -621,7 -601,7 +601,7 @@@ int valid_fetch_refspec(const char *fet struct refspec *refspec; refspec = parse_refspec_internal(1, &fetch_refspec_str, 1, 1); - free_refspecs(refspec, 1); + free_refspec(1, refspec); return !!refspec; } @@@ -638,6 -618,10 +618,10 @@@ struct refspec *parse_push_refspec(int 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); @@@ -649,12 -633,7 +633,12 @@@ static int valid_remote_nick(const cha { 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) @@@ -1196,10 -1175,9 +1180,10 @@@ static int match_explicit(struct ref *s 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"