On Tue, Sep 4, 2018 at 1:44 PM Junio C Hamano <gitster@xxxxxxxxx> wrote: > > Matthew DeVore <matvore@xxxxxxxxxx> writes: > > > @@ -50,6 +50,10 @@ static int gently_parse_list_objects_filter( > > return 0; > > } > > > > + } else if (!strcmp(arg, "tree:0")) { > > + filter_options->choice = LOFC_TREE_NONE; > > + return 0; > > + > > This is not wrong per-se, but I would have expected to see something > like: > > ... else if (skip_prefix(arg, "tree:", ¶m)) { > unsigned long depth; > if (!git_parse_ulong(param, &depth) || depth != 0) { > err = "only 'tree:0' is supported"; > return -1; > } > filter_options->choice = LOFC_TREE_NONE; > return 0; > > so that "tree:1" is rejected not with "invalid filter-spec" but a > bit more descriptive "only tree:0 is". Accepting "tree:00" or > "tree:0k" is merely an added bogus^wbonus. > Good idea. An interdiff for my fix is below. I didn't add a test, since adding a shell test for every trivial error doesn't seem to scale, but let me know if you disagree. I did of course try provoking the error manually. diff --git a/list-objects-filter-options.c b/list-objects-filter-options.c index a28382940..14f251de4 100644 --- a/list-objects-filter-options.c +++ b/list-objects-filter-options.c @@ -50,7 +50,17 @@ static int gently_parse_list_objects_filter( return 0; } - } else if (!strcmp(arg, "tree:0")) { + } else if (skip_prefix(arg, "tree:", &v0)) { + unsigned long depth; + if (!git_parse_ulong(v0, &depth) || depth != 0) { + if (errbuf) { + strbuf_init(errbuf, 0); + strbuf_addstr( + errbuf, + _("only 'tree:0' is supported")); + } + return 1; + } filter_options->choice = LOFC_TREE_NONE; return 0;