]> git.ipfire.org Git - thirdparty/git.git/blobdiff - transport.c
Merge branch 'maint-2.35' into maint-2.36
[thirdparty/git.git] / transport.c
index 050c143a8d76762fcac2ae760ad9592a26606177..d514ab9508677f108c83f938d9512b64cac0230c 100644 (file)
@@ -125,16 +125,9 @@ struct bundle_transport_data {
        unsigned get_refs_from_bundle_called : 1;
 };
 
-static struct ref *get_refs_from_bundle(struct transport *transport,
-                                       int for_push,
-                                       struct transport_ls_refs_options *transport_options)
+static void get_refs_from_bundle_inner(struct transport *transport)
 {
        struct bundle_transport_data *data = transport->data;
-       struct ref *result = NULL;
-       int i;
-
-       if (for_push)
-               return NULL;
 
        data->get_refs_from_bundle_called = 1;
 
@@ -145,6 +138,20 @@ static struct ref *get_refs_from_bundle(struct transport *transport,
                die(_("could not read bundle '%s'"), transport->url);
 
        transport->hash_algo = data->header.hash_algo;
+}
+
+static struct ref *get_refs_from_bundle(struct transport *transport,
+                                       int for_push,
+                                       struct transport_ls_refs_options *transport_options)
+{
+       struct bundle_transport_data *data = transport->data;
+       struct ref *result = NULL;
+       int i;
+
+       if (for_push)
+               return NULL;
+
+       get_refs_from_bundle_inner(transport);
 
        for (i = 0; i < data->header.references.nr; i++) {
                struct string_list_item *e = data->header.references.items + i;
@@ -169,7 +176,7 @@ static int fetch_refs_from_bundle(struct transport *transport,
                strvec_push(&extra_index_pack_args, "-v");
 
        if (!data->get_refs_from_bundle_called)
-               get_refs_from_bundle(transport, 0, NULL);
+               get_refs_from_bundle_inner(transport);
        ret = unbundle(the_repository, &data->header, data->fd,
                       &extra_index_pack_args);
        transport->hash_algo = data->header.hash_algo;
@@ -243,6 +250,9 @@ static int set_git_option(struct git_transport_options *opts,
                list_objects_filter_die_if_populated(&opts->filter_options);
                parse_list_objects_filter(&opts->filter_options, value);
                return 0;
+       } else if (!strcmp(name, TRANS_OPT_REFETCH)) {
+               opts->refetch = !!value;
+               return 0;
        } else if (!strcmp(name, TRANS_OPT_REJECT_SHALLOW)) {
                opts->reject_shallow = !!value;
                return 0;
@@ -377,6 +387,7 @@ static int fetch_refs_via_pack(struct transport *transport,
        args.update_shallow = data->options.update_shallow;
        args.from_promisor = data->options.from_promisor;
        args.filter_options = data->options.filter_options;
+       args.refetch = data->options.refetch;
        args.stateless_rpc = transport->stateless_rpc;
        args.server_options = transport->server_options;
        args.negotiation_tips = data->options.negotiation_tips;
@@ -1203,16 +1214,15 @@ static int run_pre_push_hook(struct transport *transport,
        struct ref *r;
        struct child_process proc = CHILD_PROCESS_INIT;
        struct strbuf buf;
-       const char *argv[4];
+       const char *hook_path = find_hook("pre-push");
 
-       if (!(argv[0] = find_hook("pre-push")))
+       if (!hook_path)
                return 0;
 
-       argv[1] = transport->remote->name;
-       argv[2] = transport->url;
-       argv[3] = NULL;
+       strvec_push(&proc.args, hook_path);
+       strvec_push(&proc.args, transport->remote->name);
+       strvec_push(&proc.args, transport->url);
 
-       proc.argv = argv;
        proc.in = -1;
        proc.trace2_hook_name = "pre-push";
 
@@ -1292,7 +1302,7 @@ int transport_push(struct repository *r,
                                                               &transport_options);
                trace2_region_leave("transport_push", "get_refs_list", r);
 
-               strvec_clear(&transport_options.ref_prefixes);
+               transport_ls_refs_options_release(&transport_options);
 
                if (flags & TRANSPORT_PUSH_ALL)
                        match_flags |= MATCH_REFS_ALL;
@@ -1420,6 +1430,12 @@ const struct ref *transport_get_remote_refs(struct transport *transport,
        return transport->remote_refs;
 }
 
+void transport_ls_refs_options_release(struct transport_ls_refs_options *opts)
+{
+       strvec_clear(&opts->ref_prefixes);
+       free((char *)opts->unborn_head_target);
+}
+
 int transport_fetch_refs(struct transport *transport, struct ref *refs)
 {
        int rc;
@@ -1456,13 +1472,18 @@ int transport_fetch_refs(struct transport *transport, struct ref *refs)
        return rc;
 }
 
-void transport_unlock_pack(struct transport *transport)
+void transport_unlock_pack(struct transport *transport, unsigned int flags)
 {
+       int in_signal_handler = !!(flags & TRANSPORT_UNLOCK_PACK_IN_SIGNAL_HANDLER);
        int i;
 
        for (i = 0; i < transport->pack_lockfiles.nr; i++)
-               unlink_or_warn(transport->pack_lockfiles.items[i].string);
-       string_list_clear(&transport->pack_lockfiles, 0);
+               if (in_signal_handler)
+                       unlink(transport->pack_lockfiles.items[i].string);
+               else
+                       unlink_or_warn(transport->pack_lockfiles.items[i].string);
+       if (!in_signal_handler)
+               string_list_clear(&transport->pack_lockfiles, 0);
 }
 
 int transport_connect(struct transport *transport, const char *name,