Merge branch 'jt/push-negotiation'

"git push" learns to discover common ancestor with the receiving
end over protocol v2.

* jt/push-negotiation:
  send-pack: support push negotiation
  fetch: teach independent negotiation (no packfile)
  fetch-pack: refactor command and capability write
  fetch-pack: refactor add_haves()
  fetch-pack: refactor process_acks()
This commit is contained in:
Junio C Hamano
2021-05-16 21:05:22 +09:00
14 changed files with 466 additions and 111 deletions

View File

@ -103,6 +103,7 @@ struct upload_pack_data {
unsigned use_ofs_delta : 1;
unsigned no_progress : 1;
unsigned use_include_tag : 1;
unsigned wait_for_done : 1;
unsigned allow_filter : 1;
unsigned allow_filter_fallback : 1;
unsigned long tree_filter_max_depth;
@ -1496,6 +1497,10 @@ static void process_args(struct packet_reader *request,
data->done = 1;
continue;
}
if (!strcmp(arg, "wait-for-done")) {
data->wait_for_done = 1;
continue;
}
/* Shallow related arguments */
if (process_shallow(arg, &data->shallows))
@ -1578,7 +1583,7 @@ static int send_acks(struct upload_pack_data *data, struct oid_array *acks)
oid_to_hex(&acks->oid[i]));
}
if (ok_to_give_up(data)) {
if (!data->wait_for_done && ok_to_give_up(data)) {
/* Send Ready */
packet_writer_write(&data->writer, "ready\n");
return 1;
@ -1668,10 +1673,13 @@ int upload_pack_v2(struct repository *r, struct strvec *keys,
case FETCH_PROCESS_ARGS:
process_args(request, &data);
if (!data.want_obj.nr) {
if (!data.want_obj.nr && !data.wait_for_done) {
/*
* Request didn't contain any 'want' lines,
* guess they didn't want anything.
* Request didn't contain any 'want' lines (and
* the request does not contain
* "wait-for-done", in which it is reasonable
* to just send 'have's without 'want's); guess
* they didn't want anything.
*/
state = FETCH_DONE;
} else if (data.haves.nr) {
@ -1723,7 +1731,7 @@ int upload_pack_advertise(struct repository *r,
int allow_sideband_all_value;
char *str = NULL;
strbuf_addstr(value, "shallow");
strbuf_addstr(value, "shallow wait-for-done");
if (!repo_config_get_bool(the_repository,
"uploadpack.allowfilter",