]> git.ipfire.org Git - thirdparty/git.git/commitdiff
promisor-remote: refactor accept_from_server()
authorChristian Couder <christian.couder@gmail.com>
Tue, 7 Apr 2026 11:52:40 +0000 (13:52 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 7 Apr 2026 15:45:44 +0000 (08:45 -0700)
In future commits, we are going to add more logic to
filter_promisor_remote() which is already doing a lot of things.

Let's alleviate that by moving the logic that checks and validates the
value of the `promisor.acceptFromServer` config variable into its own
accept_from_server() helper function.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
promisor-remote.c

index d60518f19c053eba557e95c8ceaf01ba40d1081f..8d80ef6040534c0c2b9bf32774518f456d3d1be2 100644 (file)
@@ -862,20 +862,12 @@ static bool promisor_store_advertised_fields(struct promisor_info *advertised,
        return reload_config;
 }
 
-static void filter_promisor_remote(struct repository *repo,
-                                  struct strvec *accepted,
-                                  const char *info)
+static enum accept_promisor accept_from_server(struct repository *repo)
 {
        const char *accept_str;
        enum accept_promisor accept = ACCEPT_NONE;
-       struct string_list config_info = STRING_LIST_INIT_NODUP;
-       struct string_list remote_info = STRING_LIST_INIT_DUP;
-       struct store_info *store_info = NULL;
-       struct string_list_item *item;
-       bool reload_config = false;
-       struct string_list accepted_filters = STRING_LIST_INIT_DUP;
 
-       if (!repo_config_get_string_tmp(the_repository, "promisor.acceptfromserver", &accept_str)) {
+       if (!repo_config_get_string_tmp(repo, "promisor.acceptfromserver", &accept_str)) {
                if (!*accept_str || !strcasecmp("None", accept_str))
                        accept = ACCEPT_NONE;
                else if (!strcasecmp("KnownUrl", accept_str))
@@ -889,6 +881,21 @@ static void filter_promisor_remote(struct repository *repo,
                                accept_str, "promisor.acceptfromserver");
        }
 
+       return accept;
+}
+
+static void filter_promisor_remote(struct repository *repo,
+                                  struct strvec *accepted,
+                                  const char *info)
+{
+       struct string_list config_info = STRING_LIST_INIT_NODUP;
+       struct string_list remote_info = STRING_LIST_INIT_DUP;
+       struct store_info *store_info = NULL;
+       struct string_list_item *item;
+       bool reload_config = false;
+       struct string_list accepted_filters = STRING_LIST_INIT_DUP;
+       enum accept_promisor accept = accept_from_server(repo);
+
        if (accept == ACCEPT_NONE)
                return;