[PATCH v6 2/4] receive-pack: drop static variables to track report status version
From: Karthik Nayak <hidden>
Date: 2026-09-03 09:28:13
Subsystem:
the rest · Maintainer:
Linus Torvalds
In 'git-receive-pack(1)', to track the report status version, we use the static variables `report_status` and `report_status_v2`. As the report status version is mutually exclusive, using an enum better suits the requirement. switch to using a new `enum report_status_version`, while also dropping the static variable to make the flow easier to understand. Helped-by: Junio C Hamano [off-list ref] Signed-off-by: Karthik Nayak <redacted> --- builtin/receive-pack.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 86933d8d7e..a9a3d21c24 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c@@ -55,6 +55,12 @@ enum deny_action { DENY_UPDATE_INSTEAD }; +enum report_status_version { + REPORT_STATUS_UNKOWN = 0, + REPORT_STATUS_V0, + REPORT_STATUS_V2, +}; + static int deny_deletes; static int deny_non_fast_forwards; static enum deny_action deny_current_branch = DENY_UNCONFIGURED;
@@ -69,8 +75,6 @@ static int advertise_push_options; static int advertise_sid; static int unpack_limit = 100; static off_t max_input_size; -static int report_status; -static int report_status_v2; static int use_sideband; static int use_atomic; static int use_push_options;
@@ -2207,7 +2211,8 @@ static void queue_commands_from_cert(struct command **tail, } static struct command *read_head_info(struct packet_reader *reader, - struct oid_array *shallow) + struct oid_array *shallow, + enum report_status_version *version) { struct command *commands = NULL; struct command **p = &commands;
@@ -2233,9 +2238,9 @@ static struct command *read_head_info(struct packet_reader *reader, const char *client_sid; size_t len = 0; if (parse_feature_request(feature_list, "report-status")) - report_status = 1; + *version = REPORT_STATUS_V0; if (parse_feature_request(feature_list, "report-status-v2")) - report_status_v2 = 1; + *version = REPORT_STATUS_V2; if (parse_feature_request(feature_list, "side-band-64k")) use_sideband = LARGE_PACKET_MAX; if (parse_feature_request(feature_list, "quiet"))
@@ -2621,6 +2626,7 @@ int cmd_receive_pack(int argc, struct shallow_info si; struct packet_reader reader; struct odb_transaction *transaction = NULL; + enum report_status_version version = REPORT_STATUS_UNKOWN; struct option options[] = { OPT__QUIET(&quiet, N_("quiet")),
@@ -2689,7 +2695,7 @@ int cmd_receive_pack(int argc, PACKET_READ_CHOMP_NEWLINE | PACKET_READ_DIE_ON_ERR_PACKET); - if ((commands = read_head_info(&reader, &shallow))) { + if ((commands = read_head_info(&reader, &shallow, &version))) { const char *unpack_status = NULL; struct string_list push_options = STRING_LIST_INIT_DUP;
@@ -2716,10 +2722,12 @@ int cmd_receive_pack(int argc, &push_options); delete_tempfile(&pack_lockfile); sigchain_push(SIGPIPE, SIG_IGN); - if (report_status_v2) + if (version == REPORT_STATUS_V2) report_v2(commands, unpack_status); - else if (report_status) + else if (version == REPORT_STATUS_V0) report(commands, unpack_status); + else + BUG("unknown report status version"); sigchain_pop(SIGPIPE); run_receive_hook(commands, "post-receive", 1, NULL, &push_options);
--
2.55.GIT