]> git.ipfire.org Git - thirdparty/git.git/blobdiff - transport.c
Sync with 2.31.5
[thirdparty/git.git] / transport.c
index ef66e73090a9886b044a6109084baf1e60dc2542..99363a422c3900b42b89d1f503c8eed4bc9791fd 100644 (file)
@@ -108,11 +108,11 @@ static void set_upstreams(struct transport *transport, struct ref *refs,
                if (!remotename || !starts_with(remotename, "refs/heads/"))
                        continue;
 
-               if (!pretend)
-                       install_branch_config(BRANCH_CONFIG_VERBOSE,
-                               localname + 11, transport->remote->name,
-                               remotename);
-               else
+               if (!pretend) {
+                       int flag = transport->verbose < 0 ? 0 : BRANCH_CONFIG_VERBOSE;
+                       install_branch_config(flag, localname + 11,
+                               transport->remote->name, remotename);
+               } else if (transport->verbose >= 0)
                        printf(_("Would set upstream of '%s' to '%s' of '%s'\n"),
                                localname + 11, remotename + 11,
                                transport->remote->name);
@@ -392,16 +392,29 @@ static int fetch_refs_via_pack(struct transport *transport,
        else if (data->version <= protocol_v1)
                die_if_server_options(transport);
 
+       if (data->options.acked_commits) {
+               if (data->version < protocol_v2) {
+                       warning(_("--negotiate-only requires protocol v2"));
+                       ret = -1;
+               } else if (!server_supports_feature("fetch", "wait-for-done", 0)) {
+                       warning(_("server does not support wait-for-done"));
+                       ret = -1;
+               } else {
+                       negotiate_using_fetch(data->options.negotiation_tips,
+                                             transport->server_options,
+                                             transport->stateless_rpc,
+                                             data->fd,
+                                             data->options.acked_commits);
+                       ret = 0;
+               }
+               goto cleanup;
+       }
+
        refs = fetch_pack(&args, data->fd,
                          refs_tmp ? refs_tmp : transport->remote_refs,
                          to_fetch, nr_heads, &data->shallow,
                          &transport->pack_lockfiles, data->version);
 
-       close(data->fd[0]);
-       close(data->fd[1]);
-       if (finish_connect(data->conn))
-               ret = -1;
-       data->conn = NULL;
        data->got_remote_heads = 0;
        data->options.self_contained_and_connected =
                args.self_contained_and_connected;
@@ -412,6 +425,13 @@ static int fetch_refs_via_pack(struct transport *transport,
        if (report_unmatched_refs(to_fetch, nr_heads))
                ret = -1;
 
+cleanup:
+       close(data->fd[0]);
+       close(data->fd[1]);
+       if (finish_connect(data->conn))
+               ret = -1;
+       data->conn = NULL;
+
        free_refs(refs_tmp);
        free_refs(refs);
        return ret;
@@ -968,8 +988,7 @@ static enum protocol_allow_config get_protocol_config(const char *type)
        if (!strcmp(type, "http") ||
            !strcmp(type, "https") ||
            !strcmp(type, "git") ||
-           !strcmp(type, "ssh") ||
-           !strcmp(type, "file"))
+           !strcmp(type, "ssh"))
                return PROTOCOL_ALLOW_ALWAYS;
 
        /* known scary; err on the side of caution */