From: Junio C Hamano Date: Thu, 12 Sep 2013 21:41:41 +0000 (-0700) Subject: Merge branch 'mm/mediawiki-dumb-push-fix' X-Git-Tag: v1.8.5-rc0~143 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/100ce1c543b8e9961ed59c047b902da1dd649666?ds=inline;hp=-c Merge branch 'mm/mediawiki-dumb-push-fix' * mm/mediawiki-dumb-push-fix: git-remote-mediawiki: no need to update private ref in non-dumb push git-remote-mediawiki: use no-private-update capability on dumb push transport-helper: add no-private-update capability git-remote-mediawiki: add test and check Makefile targets --- 100ce1c543b8e9961ed59c047b902da1dd649666 diff --combined Documentation/gitremote-helpers.txt index bc069c23df,ee9e134e94..be7e224a03 --- a/Documentation/gitremote-helpers.txt +++ b/Documentation/gitremote-helpers.txt @@@ -120,6 -120,11 +120,11 @@@ connecting (see the 'connect' command u When choosing between 'push' and 'export', Git prefers 'push'. Other frontends may have some other order of preference. + 'no-private-update':: + When using the 'refspec' capability, git normally updates the + private ref on successful push. This update is disabled when + the remote-helper declares the capability 'no-private-update'. + Capabilities for Fetching ^^^^^^^^^^^^^^^^^^^^^^^^^ @@@ -143,10 -148,6 +148,10 @@@ Supported commands: 'list', 'fetch' + Supported commands: 'list', 'import'. +'check-connectivity':: + Can guarantee that when a clone is requested, the received + pack is self contained and is connected. + If a helper advertises 'connect', Git will use it if possible and fall back to another capability if the helper requests so when connecting (see the 'connect' command under COMMANDS). @@@ -274,9 -275,6 +279,9 @@@ Optionally may output a 'lock ' l GIT_DIR/objects/pack which is keeping a pack until refs can be suitably updated. + +If option 'check-connectivity' is requested, the helper must output +'connectivity-ok' if the clone is self-contained and connected. ++ Supported if the helper has the "fetch" capability. 'push' +::: @@@ -423,9 -421,6 +428,9 @@@ set by Git if the remote helper has th must not rely on this option being set before connect request occurs. +'option check-connectivity' \{'true'|'false'\}:: + Request the helper to check connectivity of a clone. + SEE ALSO -------- linkgit:git-remote[1] diff --combined transport-helper.c index 4c2a39e8ff,3328394a9b..b32e2d64dd --- a/transport-helper.c +++ b/transport-helper.c @@@ -27,8 -27,8 +27,9 @@@ struct helper_data push : 1, connect : 1, signed_tags : 1, + check_connectivity : 1, - no_disconnect_req : 1; + no_disconnect_req : 1, + no_private_update : 1; char *export_marks; char *import_marks; /* These go from remote name (as in "list") to private name */ @@@ -187,8 -187,6 +188,8 @@@ static struct child_process *get_helper data->bidi_import = 1; else if (!strcmp(capname, "export")) data->export = 1; + else if (!strcmp(capname, "check-connectivity")) + data->check_connectivity = 1; else if (!data->refspecs && !prefixcmp(capname, "refspec ")) { ALLOC_GROW(refspecs, refspec_nr + 1, @@@ -208,6 -206,8 +209,8 @@@ strbuf_addstr(&arg, "--import-marks="); strbuf_addstr(&arg, capname + strlen("import-marks ")); data->import_marks = strbuf_detach(&arg, NULL); + } else if (!prefixcmp(capname, "no-private-update")) { + data->no_private_update = 1; } else if (mandatory) { die("Unknown mandatory capability %s. This remote " "helper probably needs newer version of Git.", @@@ -352,9 -352,6 +355,9 @@@ static int fetch_with_fetch(struct tran struct strbuf buf = STRBUF_INIT; standard_options(transport); + if (data->check_connectivity && + data->transport_options.check_self_contained_and_connected) + set_helper_option(transport, "check-connectivity", "true"); for (i = 0; i < nr_heads; i++) { const struct ref *posn = to_fetch[i]; @@@ -378,10 -375,6 +381,10 @@@ else transport->pack_lockfile = xstrdup(name); } + else if (data->check_connectivity && + data->transport_options.check_self_contained_and_connected && + !strcmp(buf.buf, "connectivity-ok")) + data->transport_options.self_contained_and_connected = 1; else if (!buf.len) break; else @@@ -693,11 -686,6 +696,11 @@@ static int push_update_ref_status(struc free(msg); msg = NULL; } + else if (!strcmp(msg, "stale info")) { + status = REF_STATUS_REJECT_STALE; + free(msg); + msg = NULL; + } } if (*ref) @@@ -738,7 -726,7 +741,7 @@@ static void push_update_refs_status(str if (push_update_ref_status(&buf, &ref, remote_refs)) continue; - if (!data->refspecs) + if (!data->refspecs || data->no_private_update) continue; /* propagate back the update to the remote namespace */ @@@ -752,15 -740,13 +755,15 @@@ } static int push_refs_with_push(struct transport *transport, - struct ref *remote_refs, int flags) + struct ref *remote_refs, int flags) { int force_all = flags & TRANSPORT_PUSH_FORCE; int mirror = flags & TRANSPORT_PUSH_MIRROR; struct helper_data *data = transport->data; struct strbuf buf = STRBUF_INIT; struct ref *ref; + struct string_list cas_options = STRING_LIST_INIT_DUP; + struct string_list_item *cas_option; get_helper(transport); if (!data->push) @@@ -773,7 -759,6 +776,7 @@@ /* Check for statuses set by set_ref_status_for_push() */ switch (ref->status) { case REF_STATUS_REJECT_NONFASTFORWARD: + case REF_STATUS_REJECT_STALE: case REF_STATUS_REJECT_ALREADY_EXISTS: case REF_STATUS_UPTODATE: continue; @@@ -796,29 -781,11 +799,29 @@@ strbuf_addch(&buf, ':'); strbuf_addstr(&buf, ref->name); strbuf_addch(&buf, '\n'); + + /* + * The "--force-with-lease" options without explicit + * values to expect have already been expanded into + * the ref->old_sha1_expect[] field; we can ignore + * transport->smart_options->cas altogether and instead + * can enumerate them from the refs. + */ + if (ref->expect_old_sha1) { + struct strbuf cas = STRBUF_INIT; + strbuf_addf(&cas, "%s:%s", + ref->name, sha1_to_hex(ref->old_sha1_expect)); + string_list_append(&cas_options, strbuf_detach(&cas, NULL)); + } } - if (buf.len == 0) + if (buf.len == 0) { + string_list_clear(&cas_options, 0); return 0; + } standard_options(transport); + for_each_string_list_item(cas_option, &cas_options) + set_helper_option(transport, "cas", cas_option->string); if (flags & TRANSPORT_PUSH_DRY_RUN) { if (set_helper_option(transport, "dry-run", "true") != 0)