Browse Source

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>
maint
Brandon Williams 7 years ago committed by Junio C Hamano
parent
commit
38490dd416
  1. 17
      http-push.c

17
http-push.c

@ -1692,8 +1692,7 @@ int cmd_main(int argc, const char **argv) @@ -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) @@ -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) @@ -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) @@ -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;
}

Loading…
Cancel
Save