From: Junio C Hamano <gitster@pobox.com>
To: "Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, me@ttaylorr.com, jonathantanmy@google.com,
christian.couder@gmail.com, git@jeffhostetler.com,
Derrick Stolee <dstolee@microsoft.com>
Subject: Re: [PATCH 1/2] partial-clone: set default filter with --partial
Date: Fri, 20 Mar 2020 13:26:42 -0700 [thread overview]
Message-ID: <xmqqr1xmbwn1.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <6f340d9aadf71d394ad320ad162f1d140b632f2c.1584638887.git.gitgitgadget@gmail.com> (Derrick Stolee via GitGitGadget's message of "Thu, 19 Mar 2020 17:28:06 +0000")
"Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes:
> diff --git a/list-objects-filter-options.c b/list-objects-filter-options.c
> index 256bcfbdfe6..a71716ef75e 100644
> --- a/list-objects-filter-options.c
> +++ b/list-objects-filter-options.c
> @@ -270,6 +270,24 @@ int opt_parse_list_objects_filter(const struct option *opt,
> return 0;
> }
>
> +int opt_set_blob_none_filter(const struct option *opt,
> + const char *arg, int unset)
Isn't the convention to use "opt_parse_" for canned parse-options
callbacks?
> +{
> + struct strbuf filter_arg = STRBUF_INIT;
> + struct list_objects_filter_options *filter_options = opt->value;
> +
> + if (unset || !arg || !strcmp(arg, "0")) {
> + parse_list_objects_filter(filter_options, "blob:none");
> + return 0;
If "--no-partial" were allowed, it should be usable to countermand
"--partial" earlier on the command line or perhaps configured
default. But the above (especially the "unset ||" part) makes
"--no-partial" a synonym to "--filter=blob:none", no?
> + }
> +
> + strbuf_addf(&filter_arg, "blob:limit=%s", arg);
> + parse_list_objects_filter(filter_options, filter_arg.buf);
> + strbuf_release(&filter_arg);
I would have expected the body of the function to read more like
this:
if (unset) {
... clear filter_options stored in opt->value ...
} else {
struct strbuf filter_arg = STRBUF_INIT;
if (!arg)
strbuf_addstr(&filter_arg, "blob:none");
else
strbuf_addf(&filter_arg, "blob:limit=%s", arg);
parse_list_objects_filter(filter_options, filter_arg.buf);
strbuf_release(&filter_arg);
}
Specifically, I find it unsatisifying to see the "0" optimization at
this level. Shouldn't it be done in parse_list_objects_filter() to
parse "blob:limit=<num>" and after realizing <num> is zero, pretend
as if it got "blob:none" to optimize? That way, people can even say
"--partial=0k" and get it interpreted as "--filter=blob:none", right?
> #define OPT_PARSE_LIST_OBJECTS_FILTER(fo) \
> { OPTION_CALLBACK, 0, CL_ARG__FILTER, fo, N_("args"), \
> N_("object filtering"), 0, \
> - opt_parse_list_objects_filter }
> + opt_parse_list_objects_filter }, \
> + { OPTION_CALLBACK, 0, CL_ARG__PARTIAL, fo, N_("size"), \
> + N_("partial clone with blob filter"), \
> + PARSE_OPT_OPTARG | PARSE_OPT_NONEG , opt_set_blob_none_filter }
PARSE_OPT_NONEG means "--no-partial" is forbidden and the callback
won't see unset==1 at all, right?
Thanks.
next prev parent reply other threads:[~2020-03-20 20:26 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-19 17:28 [PATCH 0/2] Slightly simplify partial clone user experience Derrick Stolee via GitGitGadget
2020-03-19 17:28 ` [PATCH 1/2] partial-clone: set default filter with --partial Derrick Stolee via GitGitGadget
2020-03-20 20:26 ` Junio C Hamano [this message]
2020-03-20 20:38 ` Derrick Stolee
2020-03-22 9:46 ` Jeff King
2020-03-19 17:28 ` [PATCH 2/2] clone: document --partial and --filter options Derrick Stolee via GitGitGadget
2020-03-20 12:27 ` [PATCH 0/2] Slightly simplify partial clone user experience Derrick Stolee
2020-03-22 9:51 ` Jeff King
2020-03-22 10:58 ` Christian Couder
2020-03-22 16:45 ` Derrick Stolee
2020-03-22 19:22 ` Jeff King
2020-03-22 16:03 ` Taylor Blau
2020-03-22 19:50 ` [PATCH v2] clone: document --filter options Derrick Stolee via GitGitGadget
2020-03-24 3:40 ` Jeff King
2020-03-24 5:17 ` Jonathan Nieder
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqr1xmbwn1.fsf@gitster.c.googlers.com \
--to=gitster@pobox.com \
--cc=christian.couder@gmail.com \
--cc=dstolee@microsoft.com \
--cc=git@jeffhostetler.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=jonathantanmy@google.com \
--cc=me@ttaylorr.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).