Merge branch 'bw/ref-prefix-for-configured-refspec'

"git fetch $there $refspec" that talks over protocol v2 can take
advantage of server-side ref filtering; the code has been extended
so that this mechanism triggers also when fetching with configured
refspec.

* bw/ref-prefix-for-configured-refspec: (38 commits)
  fetch: generate ref-prefixes when using a configured refspec
  refspec: consolidate ref-prefix generation logic
  submodule: convert push_unpushed_submodules to take a struct refspec
  remote: convert check_push_refs to take a struct refspec
  remote: convert match_push_refs to take a struct refspec
  http-push: store refspecs in a struct refspec
  transport: remove transport_verify_remote_names
  send-pack: store refspecs in a struct refspec
  transport: convert transport_push to take a struct refspec
  push: convert to use struct refspec
  push: check for errors earlier
  remote: convert match_explicit_refs to take a struct refspec
  remote: convert get_ref_match to take a struct refspec
  remote: convert query_refspecs to take a struct refspec
  remote: convert apply_refspecs to take a struct refspec
  remote: convert get_stale_heads to take a struct refspec
  fetch: convert prune_refs to take a struct refspec
  fetch: convert get_ref_map to take a struct refspec
  fetch: convert do_fetch to take a struct refspec
  refspec: remove the deprecated functions
  ...
This commit is contained in:
Junio C Hamano
2018-05-30 21:51:26 +09:00
23 changed files with 568 additions and 611 deletions

View File

@ -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,18 @@ 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)) {
if (match_push_refs(local_refs, &remote_refs, &rs, push_all)) {
rc = -1;
goto cleanup;
}