promisor-remote: parse remote.*.partialclonefilter
[git/git.git] / list-objects-filter-options.c
index b0de7d3..28c571f 100644 (file)
@@ -30,6 +30,9 @@ static int gently_parse_list_objects_filter(
 {
        const char *v0;
 
+       if (!arg)
+               return 0;
+
        if (filter_options->choice) {
                if (errbuf) {
                        strbuf_addstr(
@@ -148,6 +151,7 @@ void partial_clone_register(
        const struct list_objects_filter_options *filter_options)
 {
        char *cfg_name;
+       char *filter_name;
 
        /* Check if it is already registered */
        if (!promisor_remote_find(remote)) {
@@ -162,27 +166,26 @@ void partial_clone_register(
        /*
         * Record the initial filter-spec in the config as
         * the default for subsequent fetches from this remote.
-        *
-        * TODO: record it into remote.<name>.partialclonefilter
         */
-       core_partial_clone_filter_default =
-               xstrdup(filter_options->filter_spec);
-       git_config_set("core.partialclonefilter",
-                      core_partial_clone_filter_default);
+       filter_name = xstrfmt("remote.%s.partialclonefilter", remote);
+       git_config_set(filter_name, filter_options->filter_spec);
+       free(filter_name);
 
        /* Make sure the config info are reset */
        promisor_remote_reinit();
 }
 
 void partial_clone_get_default_filter_spec(
-       struct list_objects_filter_options *filter_options)
+       struct list_objects_filter_options *filter_options,
+       const char *remote)
 {
+       struct promisor_remote *promisor = promisor_remote_find(remote);
+
        /*
         * Parse default value, but silently ignore it if it is invalid.
         */
-       if (!core_partial_clone_filter_default)
-               return;
-       gently_parse_list_objects_filter(filter_options,
-                                        core_partial_clone_filter_default,
-                                        NULL);
+       if (promisor)
+               gently_parse_list_objects_filter(filter_options,
+                                                promisor->partial_clone_filter,
+                                                NULL);
 }