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@xxxxxxxxxxxxx> --- upload-pack.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index becefd5bdc..3e9ae53e6c 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -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; struct upload_pack_data { struct string_list symref; @@ -84,6 +83,8 @@ struct upload_pack_data { struct packet_writer writer; + const char *pack_objects_hook; + unsigned stateless_rpc : 1; unsigned daemon_mode : 1; @@ -133,6 +134,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(int timeout) @@ -177,10 +180,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; } @@ -1149,7 +1152,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"); -- 2.27.0.rc2.38.gc6b4ed14d2.dirty