]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'es/some-up-to-date-messages-must-stay'
authorJunio C Hamano <gitster@pobox.com>
Fri, 26 Jan 2024 16:54:45 +0000 (08:54 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 26 Jan 2024 16:54:45 +0000 (08:54 -0800)
Comment updates to help developers not to attempt to modify
messages from plumbing commands that must stay constant.

It might make sense to reassess the plumbing needs every few years,
but that should be done as a separate effort.

* es/some-up-to-date-messages-must-stay:
  messages: mark some strings with "up-to-date" not to touch

1  2 
builtin/send-pack.c
http-push.c
transport.c

diff --combined builtin/send-pack.c
index b7183be9709fd40a54162685825166945935e522,7a750b18a7bd5db87ed69c09602c2af9ddd66ce1..3df9eaad092babdbbfc47f1c5441fc43a4ccd182
@@@ -1,24 -1,25 +1,24 @@@
  #include "builtin.h"
  #include "config.h"
 -#include "commit.h"
 -#include "refs.h"
 +#include "hex.h"
  #include "pkt-line.h"
 -#include "sideband.h"
  #include "run-command.h"
  #include "remote.h"
  #include "connect.h"
  #include "send-pack.h"
  #include "quote.h"
  #include "transport.h"
 -#include "version.h"
  #include "oid-array.h"
 -#include "gpg-interface.h"
  #include "gettext.h"
  #include "protocol.h"
 +#include "parse-options.h"
 +#include "write-or-die.h"
  
  static const char * const send_pack_usage[] = {
        N_("git send-pack [--mirror] [--dry-run] [--force]\n"
           "              [--receive-pack=<git-receive-pack>]\n"
           "              [--verbose] [--thin] [--atomic]\n"
 +         "              [--[no-]signed | --signed=(true|false|if-asked)]\n"
           "              [<host>:]<directory> (--all | <ref>...)"),
        NULL,
  };
@@@ -126,25 -127,29 +126,25 @@@ static void print_helper_status(struct 
        strbuf_release(&buf);
  }
  
 -static int send_pack_config(const char *k, const char *v, void *cb)
 +static int send_pack_config(const char *k, const char *v,
 +                          const struct config_context *ctx, void *cb)
  {
 -      git_gpg_config(k, v, NULL);
 -
        if (!strcmp(k, "push.gpgsign")) {
 -              const char *value;
 -              if (!git_config_get_value("push.gpgsign", &value)) {
 -                      switch (git_parse_maybe_bool(value)) {
 -                      case 0:
 -                              args.push_cert = SEND_PACK_PUSH_CERT_NEVER;
 -                              break;
 -                      case 1:
 -                              args.push_cert = SEND_PACK_PUSH_CERT_ALWAYS;
 -                              break;
 -                      default:
 -                              if (value && !strcasecmp(value, "if-asked"))
 -                                      args.push_cert = SEND_PACK_PUSH_CERT_IF_ASKED;
 -                              else
 -                                      return error(_("invalid value for '%s'"), k);
 -                      }
 +              switch (git_parse_maybe_bool(v)) {
 +              case 0:
 +                      args.push_cert = SEND_PACK_PUSH_CERT_NEVER;
 +                      break;
 +              case 1:
 +                      args.push_cert = SEND_PACK_PUSH_CERT_ALWAYS;
 +                      break;
 +              default:
 +                      if (!strcasecmp(v, "if-asked"))
 +                              args.push_cert = SEND_PACK_PUSH_CERT_IF_ASKED;
 +                      else
 +                              return error(_("invalid value for '%s'"), k);
                }
        }
 -      return git_default_config(k, v, cb);
 +      return git_default_config(k, v, ctx, cb);
  }
  
  int cmd_send_pack(int argc, const char **argv, const char *prefix)
                OPT_BOOL(0, "stateless-rpc", &stateless_rpc, N_("use stateless RPC protocol")),
                OPT_BOOL(0, "stdin", &from_stdin, N_("read refs from stdin")),
                OPT_BOOL(0, "helper-status", &helper_status, N_("print status from remote helper")),
 -              OPT_CALLBACK_F(0, CAS_OPT_NAME, &cas, N_("<refname>:<expect>"),
 +              OPT_CALLBACK_F(0, "force-with-lease", &cas, N_("<refname>:<expect>"),
                  N_("require old value of ref to be at this value"),
                  PARSE_OPT_OPTARG, parseopt_push_cas_option),
                OPT_BOOL(0, TRANS_OPT_FORCE_IF_INCLUDES, &force_if_includes,
                fd[0] = 0;
                fd[1] = 1;
        } else {
 -              conn = git_connect(fd, dest, receivepack,
 +              conn = git_connect(fd, dest, "git-receive-pack", receivepack,
                        args.verbose ? CONNECT_VERBOSE : 0);
        }
  
        }
  
        if (!ret && !transport_refs_pushed(remote_refs))
+               /* stable plumbing output; do not modify or localize */
                fprintf(stderr, "Everything up-to-date\n");
  
        return ret;
diff --combined http-push.c
index b4d0b2a6aa381f4edb1bd890de4a4be1d10ab8fb,785b3193429e0dcdde1c04211466a424a882b8a5..12d111374107a7a071ac90d035c5172af2b63c79
@@@ -1,23 -1,19 +1,23 @@@
 -#include "cache.h"
 +#include "git-compat-util.h"
 +#include "environment.h"
 +#include "hex.h"
  #include "repository.h"
  #include "commit.h"
  #include "tag.h"
  #include "blob.h"
  #include "http.h"
 -#include "refs.h"
  #include "diff.h"
  #include "revision.h"
 -#include "exec-cmd.h"
  #include "remote.h"
  #include "list-objects.h"
 +#include "setup.h"
  #include "sigchain.h"
  #include "strvec.h"
 +#include "tree.h"
 +#include "tree-walk.h"
 +#include "url.h"
  #include "packfile.h"
 -#include "object-store.h"
 +#include "object-store-ll.h"
  #include "commit-reach.h"
  
  #ifdef EXPAT_NEEDS_XMLPARSE_H
@@@ -366,8 -362,7 +366,8 @@@ static void start_put(struct transfer_r
        ssize_t size;
        git_zstream stream;
  
 -      unpacked = read_object_file(&request->obj->oid, &type, &len);
 +      unpacked = repo_read_object_file(the_repository, &request->obj->oid,
 +                                       &type, &len);
        hdrlen = format_object_header(hdr, sizeof(hdr), type, len);
  
        /* Set it up */
@@@ -606,7 -601,7 +606,7 @@@ static void finish_request(struct trans
  }
  
  static int is_running_queue;
 -static int fill_active_slot(void *unused)
 +static int fill_active_slot(void *data UNUSED)
  {
        struct transfer_request *request;
  
@@@ -782,7 -777,7 +782,7 @@@ static void handle_new_lock_ctx(struct 
  static void one_remote_ref(const char *refname);
  
  static void
 -xml_start_tag(void *userData, const char *name, const char **atts)
 +xml_start_tag(void *userData, const char *name, const char **atts UNUSED)
  {
        struct xml_ctx *ctx = (struct xml_ctx *)userData;
        const char *c = strchr(name, ':');
@@@ -1336,8 -1331,7 +1336,8 @@@ static int get_delta(struct rev_info *r
        int count = 0;
  
        while ((commit = get_revision(revs)) != NULL) {
 -              p = process_tree(get_commit_tree(commit), p);
 +              p = process_tree(repo_get_commit_tree(the_repository, commit),
 +                               p);
                commit->object.flags |= LOCAL;
                if (!(commit->object.flags & UNINTERESTING))
                        count += add_send_request(&commit->object, lock);
@@@ -1432,7 -1426,7 +1432,7 @@@ static void one_remote_ref(const char *
         * Fetch a copy of the object if it doesn't exist locally - it
         * may be required for updating server info later.
         */
 -      if (repo->can_update_info_refs && !has_object_file(&ref->old_oid)) {
 +      if (repo->can_update_info_refs && !repo_has_object_file(the_repository, &ref->old_oid)) {
                obj = lookup_unknown_object(the_repository, &ref->old_oid);
                fprintf(stderr, "  fetch %s for %s\n",
                        oid_to_hex(&ref->old_oid), refname);
@@@ -1576,7 -1570,7 +1576,7 @@@ static int verify_merge_base(struct obj
        struct commit *branch = lookup_commit_or_die(&remote->old_oid,
                                                     remote->name);
  
 -      return in_merge_bases(branch, head);
 +      return repo_in_merge_bases(the_repository, branch, head);
  }
  
  static int delete_remote_branch(const char *pattern, int force)
                        return error("Remote HEAD symrefs too deep");
                if (is_null_oid(&head_oid))
                        return error("Unable to resolve remote HEAD");
 -              if (!has_object_file(&head_oid))
 +              if (!repo_has_object_file(the_repository, &head_oid))
                        return error("Remote HEAD resolves to object %s\nwhich does not exist locally, perhaps you need to fetch?", oid_to_hex(&head_oid));
  
                /* Remote branch must resolve to a known object */
                if (is_null_oid(&remote_ref->old_oid))
                        return error("Unable to resolve remote branch %s",
                                     remote_ref->name);
 -              if (!has_object_file(&remote_ref->old_oid))
 +              if (!repo_has_object_file(the_repository, &remote_ref->old_oid))
                        return error("Remote branch %s resolves to object %s\nwhich does not exist locally, perhaps you need to fetch?", remote_ref->name, oid_to_hex(&remote_ref->old_oid));
  
                /* Remote branch must be an ancestor of remote HEAD */
@@@ -1851,6 -1845,7 +1851,7 @@@ int cmd_main(int argc, const char **arg
  
                if (oideq(&ref->old_oid, &ref->peer_ref->new_oid)) {
                        if (push_verbosely)
+                               /* stable plumbing output; do not modify or localize */
                                fprintf(stderr, "'%s': up-to-date\n", ref->name);
                        if (helper_status)
                                printf("ok %s up to date\n", ref->name);
                if (!force_all &&
                    !is_null_oid(&ref->old_oid) &&
                    !ref->force) {
 -                      if (!has_object_file(&ref->old_oid) ||
 +                      if (!repo_has_object_file(the_repository, &ref->old_oid) ||
                            !ref_newer(&ref->peer_ref->new_oid,
                                       &ref->old_oid)) {
                                /*
                                 * commits at the remote end and likely
                                 * we were not up to date to begin with.
                                 */
+                               /* stable plumbing output; do not modify or localize */
                                error("remote '%s' is not an ancestor of\n"
                                      "local '%s'.\n"
                                      "Maybe you are not up-to-date and "
diff --combined transport.c
index bd7899e9bf5550b2b333dbbcf85a5b98c7813ad2,f5d5c2281242621abeadbd96b9dca3101200d648..df518ead70c387dd354dd69a5ee4af8a3ab0d560
@@@ -1,8 -1,5 +1,8 @@@
 -#include "cache.h"
 +#include "git-compat-util.h"
 +#include "advice.h"
  #include "config.h"
 +#include "environment.h"
 +#include "hex.h"
  #include "transport.h"
  #include "hook.h"
  #include "pkt-line.h"
@@@ -10,8 -7,9 +10,8 @@@
  #include "remote.h"
  #include "connect.h"
  #include "send-pack.h"
 -#include "walker.h"
  #include "bundle.h"
 -#include "dir.h"
 +#include "gettext.h"
  #include "refs.h"
  #include "refspec.h"
  #include "branch.h"
  #include "string-list.h"
  #include "oid-array.h"
  #include "sigchain.h"
 +#include "trace2.h"
  #include "transport-internal.h"
  #include "protocol.h"
 -#include "object-store.h"
 +#include "object-name.h"
  #include "color.h"
 +#include "bundle-uri.h"
  
  static int transport_use_color = -1;
  static char transport_colors[][COLOR_MAXLEN] = {
@@@ -170,8 -166,7 +170,8 @@@ static struct ref *get_refs_from_bundle
  }
  
  static int fetch_refs_from_bundle(struct transport *transport,
 -                             int nr_heads, struct ref **to_fetch)
 +                                int nr_heads UNUSED,
 +                                struct ref **to_fetch UNUSED)
  {
        struct bundle_transport_data *data = transport->data;
        struct strvec extra_index_pack_args = STRVEC_INIT;
        if (!data->get_refs_from_bundle_called)
                get_refs_from_bundle_inner(transport);
        ret = unbundle(the_repository, &data->header, data->fd,
 -                     &extra_index_pack_args);
 +                     &extra_index_pack_args, 0);
        transport->hash_algo = data->header.hash_algo;
        return ret;
  }
@@@ -202,7 -197,7 +202,7 @@@ struct git_transport_data 
        struct git_transport_options options;
        struct child_process *conn;
        int fd[2];
 -      unsigned got_remote_heads : 1;
 +      unsigned finished_handshake : 1;
        enum protocol_version version;
        struct oid_array extra_have;
        struct oid_array shallow;
@@@ -280,12 -275,8 +280,12 @@@ static int connect_setup(struct transpo
        }
  
        data->conn = git_connect(data->fd, transport->url,
 -                               for_push ? data->options.receivepack :
 -                               data->options.uploadpack,
 +                               for_push ?
 +                                      "git-receive-pack" :
 +                                      "git-upload-pack",
 +                               for_push ?
 +                                      data->options.receivepack :
 +                                      data->options.uploadpack,
                                 flags);
  
        return 0;
@@@ -315,7 -306,7 +315,7 @@@ static struct ref *handshake(struct tra
        struct git_transport_data *data = transport->data;
        struct ref *refs = NULL;
        struct packet_reader reader;
 -      int sid_len;
 +      size_t sid_len;
        const char *server_sid;
  
        connect_setup(transport, for_push);
        case protocol_unknown_version:
                BUG("unknown protocol version");
        }
 -      data->got_remote_heads = 1;
 +      data->finished_handshake = 1;
        transport->hash_algo = reader.hash_algo;
  
        if (reader.line_peeked)
@@@ -368,39 -359,6 +368,39 @@@ static struct ref *get_refs_via_connect
        return handshake(transport, for_push, options, 1);
  }
  
 +static int get_bundle_uri(struct transport *transport)
 +{
 +      struct git_transport_data *data = transport->data;
 +      struct packet_reader reader;
 +      int stateless_rpc = transport->stateless_rpc;
 +
 +      if (!transport->bundles) {
 +              CALLOC_ARRAY(transport->bundles, 1);
 +              init_bundle_list(transport->bundles);
 +      }
 +
 +      if (!data->finished_handshake) {
 +              struct ref *refs = handshake(transport, 0, NULL, 0);
 +
 +              if (refs)
 +                      free_refs(refs);
 +      }
 +
 +      /*
 +       * "Support" protocol v0 and v2 without bundle-uri support by
 +       * silently degrading to a NOOP.
 +       */
 +      if (!server_supports_v2("bundle-uri"))
 +              return 0;
 +
 +      packet_reader_init(&reader, data->fd[0], NULL, 0,
 +                         PACKET_READ_CHOMP_NEWLINE |
 +                         PACKET_READ_GENTLE_ON_EOF);
 +
 +      return get_remote_bundle_uri(data->fd[1], &reader,
 +                                   transport->bundles, stateless_rpc);
 +}
 +
  static int fetch_refs_via_pack(struct transport *transport,
                               int nr_heads, struct ref **to_fetch)
  {
        args.negotiation_tips = data->options.negotiation_tips;
        args.reject_shallow_remote = transport->smart_options->reject_shallow;
  
 -      if (!data->got_remote_heads) {
 +      if (!data->finished_handshake) {
                int i;
                int must_list_refs = 0;
                for (i = 0; i < nr_heads; i++) {
                          to_fetch, nr_heads, &data->shallow,
                          &transport->pack_lockfiles, data->version);
  
 -      data->got_remote_heads = 0;
 +      data->finished_handshake = 0;
        data->options.self_contained_and_connected =
                args.self_contained_and_connected;
        data->options.connectivity_checked = args.connectivity_checked;
@@@ -784,8 -742,7 +784,8 @@@ static int print_one_push_status(struc
  static int measure_abbrev(const struct object_id *oid, int sofar)
  {
        char hex[GIT_MAX_HEXSZ + 1];
 -      int w = find_unique_abbrev_r(hex, oid, DEFAULT_ABBREV);
 +      int w = repo_find_unique_abbrev_r(the_repository, hex, oid,
 +                                        DEFAULT_ABBREV);
  
        return (w < sofar) ? sofar : w;
  }
@@@ -862,7 -819,7 +862,7 @@@ static int git_transport_push(struct tr
        if (transport_color_config() < 0)
                return -1;
  
 -      if (!data->got_remote_heads)
 +      if (!data->finished_handshake)
                get_refs_via_connect(transport, 1, NULL);
  
        memset(&args, 0, sizeof(args));
        else
                ret = finish_connect(data->conn);
        data->conn = NULL;
 -      data->got_remote_heads = 0;
 +      data->finished_handshake = 0;
  
        return ret;
  }
@@@ -920,7 -877,7 +920,7 @@@ static int connect_git(struct transpor
  {
        struct git_transport_data *data = transport->data;
        data->conn = git_connect(data->fd, transport->url,
 -                               executable, 0);
 +                               name, executable, 0);
        fd[0] = data->fd[0];
        fd[1] = data->fd[1];
        return 0;
@@@ -930,7 -887,7 +930,7 @@@ static int disconnect_git(struct transp
  {
        struct git_transport_data *data = transport->data;
        if (data->conn) {
 -              if (data->got_remote_heads && !transport->stateless_rpc)
 +              if (data->finished_handshake && !transport->stateless_rpc)
                        packet_flush(data->fd[1]);
                close(data->fd[0]);
                if (data->fd[1] >= 0)
  
  static struct transport_vtable taken_over_vtable = {
        .get_refs_list  = get_refs_via_connect,
 +      .get_bundle_uri = get_bundle_uri,
        .fetch_refs     = fetch_refs_via_pack,
        .push_refs      = git_transport_push,
        .disconnect     = disconnect_git
@@@ -965,7 -921,7 +965,7 @@@ void transport_take_over(struct transpo
        data->conn = child;
        data->fd[0] = data->conn->out;
        data->fd[1] = data->conn->in;
 -      data->got_remote_heads = 0;
 +      data->finished_handshake = 0;
        transport->data = data;
  
        transport->vtable = &taken_over_vtable;
@@@ -1098,7 -1054,6 +1098,7 @@@ static struct transport_vtable bundle_v
  
  static struct transport_vtable builtin_smart_vtable = {
        .get_refs_list  = get_refs_via_connect,
 +      .get_bundle_uri = get_bundle_uri,
        .fetch_refs     = fetch_refs_via_pack,
        .push_refs      = git_transport_push,
        .connect        = connect_git,
@@@ -1113,9 -1068,6 +1113,9 @@@ struct transport *transport_get(struct 
        ret->progress = isatty(2);
        string_list_init_dup(&ret->pack_lockfiles);
  
 +      CALLOC_ARRAY(ret->bundles, 1);
 +      init_bundle_list(ret->bundles);
 +
        if (!remote)
                BUG("No remote provided to transport_get()");
  
                ret->smart_options = &(data->options);
  
                data->conn = NULL;
 -              data->got_remote_heads = 0;
 +              data->finished_handshake = 0;
        } else {
                /* Unknown protocol in URL. Pass to external handler. */
                int len = external_specification_len(url);
@@@ -1467,6 -1419,7 +1467,7 @@@ int transport_push(struct repository *r
        if (porcelain && !push_ret)
                puts("Done");
        else if (!quiet && !ret && !transport_refs_pushed(remote_refs))
+               /* stable plumbing output; do not modify or localize */
                fprintf(stderr, "Everything up-to-date\n");
  
  done:
@@@ -1530,34 -1483,6 +1531,34 @@@ int transport_fetch_refs(struct transpo
        return rc;
  }
  
 +int transport_get_remote_bundle_uri(struct transport *transport)
 +{
 +      int value = 0;
 +      const struct transport_vtable *vtable = transport->vtable;
 +
 +      /* Check config only once. */
 +      if (transport->got_remote_bundle_uri)
 +              return 0;
 +      transport->got_remote_bundle_uri = 1;
 +
 +      /*
 +       * Don't request bundle-uri from the server unless configured to
 +       * do so by the transfer.bundleURI=true config option.
 +       */
 +      if (git_config_get_bool("transfer.bundleuri", &value) || !value)
 +              return 0;
 +
 +      if (!transport->bundles->baseURI)
 +              transport->bundles->baseURI = xstrdup(transport->url);
 +
 +      if (!vtable->get_bundle_uri)
 +              return error(_("bundle-uri operation not supported by protocol"));
 +
 +      if (vtable->get_bundle_uri(transport) < 0)
 +              return error(_("could not retrieve server-advertised bundle-uri list"));
 +      return 0;
 +}
 +
  void transport_unlock_pack(struct transport *transport, unsigned int flags)
  {
        int in_signal_handler = !!(flags & TRANSPORT_UNLOCK_PACK_IN_SIGNAL_HANDLER);
@@@ -1588,8 -1513,6 +1589,8 @@@ int transport_disconnect(struct transpo
                ret = transport->vtable->disconnect(transport);
        if (transport->got_remote_refs)
                free_refs((void *)transport->remote_refs);
 +      clear_bundle_list(transport->bundles);
 +      free(transport->bundles);
        free(transport);
        return ret;
  }