http-push: store refspecs in a struct refspec

Convert http-push.c to store refspecs in a 'struct refspec' instead of in an array of 'const char *'. Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Brandon Williams committed May 16, 2018 at 15:58 UTC 38490dd416af41ce65eab0fc91de14009c73d606
1 file changed +8 -9
http-push.c
+8 -9
@@ -1692,8 +1692,7 @@ int cmd_main(int argc, const char **argv)
1692 {
1693 struct transfer_request *request;
1694 struct transfer_request *next_request;
1695 - int nr_refspec = 0;
1696 - const char **refspec = NULL;
1695 + struct refspec rs = REFSPEC_INIT_PUSH;
1696 struct remote_lock *ref_lock = NULL;
1697 struct remote_lock *info_ref_lock = NULL;
1698 struct rev_info revs;
@@ -1756,8 +1755,7 @@ int cmd_main(int argc, const char **argv)
1755 }
1756 continue;
1757 }
1759 - refspec = argv;
1760 - nr_refspec = argc - i;
1758 + refspec_appendn(&rs, argv, argc - i);
1759 break;
1760 }
1761
@@ -1768,7 +1766,7 @@ int cmd_main(int argc, const char **argv)
1766 if (!repo->url)
1767 usage(http_push_usage);
1768
1771 - if (delete_branch && nr_refspec != 1)
1769 + if (delete_branch && rs.nr != 1)
1770 die("You must specify only one branch name when deleting a remote branch");
1771
1772 setup_git_directory();
@@ -1814,18 +1812,19 @@ int cmd_main(int argc, const char **argv)
1812
1813 /* Remove a remote branch if -d or -D was specified */
1814 if (delete_branch) {
1817 - if (delete_remote_branch(refspec[0], force_delete) == -1) {
1815 + const char *branch = rs.items[i].src;
1816 + if (delete_remote_branch(branch, force_delete) == -1) {
1817 fprintf(stderr, "Unable to delete remote branch %s\n",
1819 - refspec[0]);
1818 + branch);
1819 if (helper_status)
1821 - printf("error %s cannot remove\n", refspec[0]);
1820 + printf("error %s cannot remove\n", branch);
1821 }
1822 goto cleanup;
1823 }
1824
1825 /* match them up */
1826 if (match_push_refs(local_refs, &remote_refs,
1828 - nr_refspec, (const char **) refspec, push_all)) {
1827 + rs.raw_nr, rs.raw, push_all)) {
1828 rc = -1;
1829 goto cleanup;
1830 }