Skip to content

Commit 7557a56

Browse files
chriscoolgitster
authored andcommitted
promisor-remote: refactor accept_from_server()
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>
1 parent 16a4372 commit 7557a56

1 file changed

Lines changed: 17 additions & 10 deletions

File tree

promisor-remote.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -862,20 +862,12 @@ static bool promisor_store_advertised_fields(struct promisor_info *advertised,
862862
return reload_config;
863863
}
864864

865-
static void filter_promisor_remote(struct repository *repo,
866-
struct strvec *accepted,
867-
const char *info)
865+
static enum accept_promisor accept_from_server(struct repository *repo)
868866
{
869867
const char *accept_str;
870868
enum accept_promisor accept = ACCEPT_NONE;
871-
struct string_list config_info = STRING_LIST_INIT_NODUP;
872-
struct string_list remote_info = STRING_LIST_INIT_DUP;
873-
struct store_info *store_info = NULL;
874-
struct string_list_item *item;
875-
bool reload_config = false;
876-
struct string_list accepted_filters = STRING_LIST_INIT_DUP;
877869

878-
if (!repo_config_get_string_tmp(the_repository, "promisor.acceptfromserver", &accept_str)) {
870+
if (!repo_config_get_string_tmp(repo, "promisor.acceptfromserver", &accept_str)) {
879871
if (!*accept_str || !strcasecmp("None", accept_str))
880872
accept = ACCEPT_NONE;
881873
else if (!strcasecmp("KnownUrl", accept_str))
@@ -889,6 +881,21 @@ static void filter_promisor_remote(struct repository *repo,
889881
accept_str, "promisor.acceptfromserver");
890882
}
891883

884+
return accept;
885+
}
886+
887+
static void filter_promisor_remote(struct repository *repo,
888+
struct strvec *accepted,
889+
const char *info)
890+
{
891+
struct string_list config_info = STRING_LIST_INIT_NODUP;
892+
struct string_list remote_info = STRING_LIST_INIT_DUP;
893+
struct store_info *store_info = NULL;
894+
struct string_list_item *item;
895+
bool reload_config = false;
896+
struct string_list accepted_filters = STRING_LIST_INIT_DUP;
897+
enum accept_promisor accept = accept_from_server(repo);
898+
892899
if (accept == ACCEPT_NONE)
893900
return;
894901

0 commit comments

Comments
 (0)