aboutsummaryrefslogtreecommitdiffstats
path: root/http-push.c
diff options
context:
space:
mode:
authorBrandon Williams <bmwill@google.com>2018-05-16 15:58:20 -0700
committerJunio C Hamano <gitster@pobox.com>2018-05-18 06:19:44 +0900
commit38490dd416af41ce65eab0fc91de14009c73d606 (patch)
treeb36f0e9944cf81f40f97061ba7e37166e529e2f1 /http-push.c
parent7a78a82b6c3bb2a6ebaddf3354b6d97939bdb2ab (diff)
downloadgit-38490dd416af41ce65eab0fc91de14009c73d606.tar.gz
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>
Diffstat (limited to 'http-push.c')
-rw-r--r--http-push.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/http-push.c b/http-push.c
index f308ce0195..a724ef03f9 100644
--- a/http-push.c
+++ b/http-push.c
@@ -1692,8 +1692,7 @@ int cmd_main(int argc, const char **argv)
{
struct transfer_request *request;
struct transfer_request *next_request;
- int nr_refspec = 0;
- const char **refspec = NULL;
+ struct refspec rs = REFSPEC_INIT_PUSH;
struct remote_lock *ref_lock = NULL;
struct remote_lock *info_ref_lock = NULL;
struct rev_info revs;
@@ -1756,8 +1755,7 @@ int cmd_main(int argc, const char **argv)
}
continue;
}
- refspec = argv;
- nr_refspec = argc - i;
+ refspec_appendn(&rs, argv, argc - i);
break;
}
@@ -1768,7 +1766,7 @@ int cmd_main(int argc, const char **argv)
if (!repo->url)
usage(http_push_usage);
- if (delete_branch && nr_refspec != 1)
+ if (delete_branch && rs.nr != 1)
die("You must specify only one branch name when deleting a remote branch");
setup_git_directory();
@@ -1814,18 +1812,19 @@ int cmd_main(int argc, const char **argv)
/* Remove a remote branch if -d or -D was specified */
if (delete_branch) {
- if (delete_remote_branch(refspec[0], force_delete) == -1) {
+ const char *branch = rs.items[i].src;
+ if (delete_remote_branch(branch, force_delete) == -1) {
fprintf(stderr, "Unable to delete remote branch %s\n",
- refspec[0]);
+ branch);
if (helper_status)
- printf("error %s cannot remove\n", refspec[0]);
+ printf("error %s cannot remove\n", branch);
}
goto cleanup;
}
/* match them up */
if (match_push_refs(local_refs, &remote_refs,
- nr_refspec, (const char **) refspec, push_all)) {
+ rs.raw_nr, rs.raw, push_all)) {
rc = -1;
goto cleanup;
}