]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'mm/mediawiki-dumb-push-fix'
authorJunio C Hamano <gitster@pobox.com>
Thu, 12 Sep 2013 21:41:41 +0000 (14:41 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 12 Sep 2013 21:41:41 +0000 (14:41 -0700)
* 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

1  2 
Documentation/gitremote-helpers.txt
transport-helper.c

index bc069c23df85ae200d8b21fdf9a4662c72152377,ee9e134e949201f0fbcb342207b8951ef2f41052..be7e224a03c4c5079342c3bbb23b39ad38ca9a5c
@@@ -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 <file>' 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' +<src>:<dst>::
@@@ -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 4c2a39e8ff03df5285657a5c0f9b7746c28d76a6,3328394a9bb54d659747030729e2b5e86e7194a0..b32e2d64dd344c3f8c4d5f42b6c48dd6bdb8d29f
@@@ -27,8 -27,8 +27,9 @@@ struct helper_data 
                push : 1,
                connect : 1,
                signed_tags : 1,
-               no_disconnect_req : 1;
 +              check_connectivity : 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,
                        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];
                        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 */
  }
  
  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)
                /* 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;
                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)