]> git.ipfire.org Git - thirdparty/git.git/commitdiff
upload-pack: move pack_objects_hook to upload_pack_data
authorChristian Couder <christian.couder@gmail.com>
Thu, 4 Jun 2020 17:54:50 +0000 (19:54 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 4 Jun 2020 17:58:27 +0000 (10:58 -0700)
As we cleanup 'upload-pack.c' by using 'struct upload_pack_data'
more thoroughly, let's move the 'pack_objects_hook' static
variable into this struct.

It is used by code common to protocol v0 and protocol v2.

While at it let's also free() it in upload_pack_data_clear().

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
upload-pack.c

index 78b10a89eaac9b64f9705177bc7be72b2547ed12..bc7e3ca19dd4deea074b0680083f4fde1c5b1910 100644 (file)
@@ -53,7 +53,6 @@ static timestamp_t oldest_have;
 static unsigned int allow_unadvertised_object_request;
 static int shallow_nr;
 static struct object_array extra_edge_obj;
-static const char *pack_objects_hook;
 
 /*
  * Please annotate, and if possible group together, fields used only
@@ -88,6 +87,8 @@ struct upload_pack_data {
 
        struct packet_writer writer;
 
+       const char *pack_objects_hook;
+
        unsigned stateless_rpc : 1;                             /* v0 only */
        unsigned no_done : 1;                                   /* v0 only */
        unsigned daemon_mode : 1;                               /* v0 only */
@@ -137,6 +138,8 @@ static void upload_pack_data_clear(struct upload_pack_data *data)
        object_array_clear(&data->shallows);
        string_list_clear(&data->deepen_not, 0);
        list_objects_filter_release(&data->filter_options);
+
+       free((char *)data->pack_objects_hook);
 }
 
 static void reset_timeout(unsigned int timeout)
@@ -181,10 +184,10 @@ static void create_pack_file(struct upload_pack_data *pack_data)
        int i;
        FILE *pipe_fd;
 
-       if (!pack_objects_hook)
+       if (!pack_data->pack_objects_hook)
                pack_objects.git_cmd = 1;
        else {
-               argv_array_push(&pack_objects.args, pack_objects_hook);
+               argv_array_push(&pack_objects.args, pack_data->pack_objects_hook);
                argv_array_push(&pack_objects.args, "git");
                pack_objects.use_shell = 1;
        }
@@ -1153,7 +1156,7 @@ static int upload_pack_config(const char *var, const char *value, void *cb_data)
        if (current_config_scope() != CONFIG_SCOPE_LOCAL &&
        current_config_scope() != CONFIG_SCOPE_WORKTREE) {
                if (!strcmp("uploadpack.packobjectshook", var))
-                       return git_config_string(&pack_objects_hook, var, value);
+                       return git_config_string(&data->pack_objects_hook, var, value);
        }
 
        return parse_hide_refs_config(var, value, "uploadpack");