Skip to content

Commit 339a984

Browse files
chriscoolgitster
authored andcommitted
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 <[email protected]> Acked-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e3835cd commit 339a984

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

upload-pack.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ static timestamp_t oldest_have;
5353
static unsigned int allow_unadvertised_object_request;
5454
static int shallow_nr;
5555
static struct object_array extra_edge_obj;
56-
static const char *pack_objects_hook;
5756

5857
/*
5958
* Please annotate, and if possible group together, fields used only
@@ -88,6 +87,8 @@ struct upload_pack_data {
8887

8988
struct packet_writer writer;
9089

90+
const char *pack_objects_hook;
91+
9192
unsigned stateless_rpc : 1; /* v0 only */
9293
unsigned no_done : 1; /* v0 only */
9394
unsigned daemon_mode : 1; /* v0 only */
@@ -137,6 +138,8 @@ static void upload_pack_data_clear(struct upload_pack_data *data)
137138
object_array_clear(&data->shallows);
138139
string_list_clear(&data->deepen_not, 0);
139140
list_objects_filter_release(&data->filter_options);
141+
142+
free((char *)data->pack_objects_hook);
140143
}
141144

142145
static void reset_timeout(unsigned int timeout)
@@ -181,10 +184,10 @@ static void create_pack_file(struct upload_pack_data *pack_data)
181184
int i;
182185
FILE *pipe_fd;
183186

184-
if (!pack_objects_hook)
187+
if (!pack_data->pack_objects_hook)
185188
pack_objects.git_cmd = 1;
186189
else {
187-
argv_array_push(&pack_objects.args, pack_objects_hook);
190+
argv_array_push(&pack_objects.args, pack_data->pack_objects_hook);
188191
argv_array_push(&pack_objects.args, "git");
189192
pack_objects.use_shell = 1;
190193
}
@@ -1153,7 +1156,7 @@ static int upload_pack_config(const char *var, const char *value, void *cb_data)
11531156
if (current_config_scope() != CONFIG_SCOPE_LOCAL &&
11541157
current_config_scope() != CONFIG_SCOPE_WORKTREE) {
11551158
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);
11571160
}
11581161

11591162
return parse_hide_refs_config(var, value, "uploadpack");

0 commit comments

Comments
 (0)