@matheusbsbs / matheus-bagliano / commits / 339a9840ef
Fork 0

upload-pack: move pack_objects_hook to upload_pack_data

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>

Christian Couder committed Jun 4, 2020 at 19:54 UTC 339a9840ef8258a75e07fee640ccceecd20ade31
1 file changed +7 -4
upload-pack.c
+7 -4
@@ -53,7 +53,6 @@ static timestamp_t oldest_have;
53 static unsigned int allow_unadvertised_object_request;
54 static int shallow_nr;
55 static struct object_array extra_edge_obj;
56 -static const char *pack_objects_hook;
56
57 /*
58 * Please annotate, and if possible group together, fields used only
@@ -88,6 +87,8 @@ struct upload_pack_data {
87
88 struct packet_writer writer;
89
90 + const char *pack_objects_hook;
91 +
92 unsigned stateless_rpc : 1; /* v0 only */
93 unsigned no_done : 1; /* v0 only */
94 unsigned daemon_mode : 1; /* v0 only */
@@ -137,6 +138,8 @@ static void upload_pack_data_clear(struct upload_pack_data *data)
138 object_array_clear(&data->shallows);
139 string_list_clear(&data->deepen_not, 0);
140 list_objects_filter_release(&data->filter_options);
141 +
142 + free((char *)data->pack_objects_hook);
143 }
144
145 static void reset_timeout(unsigned int timeout)
@@ -181,10 +184,10 @@ static void create_pack_file(struct upload_pack_data *pack_data)
184 int i;
185 FILE *pipe_fd;
186
184 - if (!pack_objects_hook)
187 + if (!pack_data->pack_objects_hook)
188 pack_objects.git_cmd = 1;
189 else {
187 - argv_array_push(&pack_objects.args, pack_objects_hook);
190 + argv_array_push(&pack_objects.args, pack_data->pack_objects_hook);
191 argv_array_push(&pack_objects.args, "git");
192 pack_objects.use_shell = 1;
193 }
@@ -1153,7 +1156,7 @@ static int upload_pack_config(const char *var, const char *value, void *cb_data)
1156 if (current_config_scope() != CONFIG_SCOPE_LOCAL &&
1157 current_config_scope() != CONFIG_SCOPE_WORKTREE) {
1158 if (!strcmp("uploadpack.packobjectshook", var))
1156 - return git_config_string(&pack_objects_hook, var, value);
1159 + return git_config_string(&data->pack_objects_hook, var, value);
1160 }
1161
1162 return parse_hide_refs_config(var, value, "uploadpack");