git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Jeff Hostetler <git@jeffhostetler.com>
Cc: Stefan Beller <sbeller@google.com>, git <git@vger.kernel.org>,
	Junio C Hamano <gitster@pobox.com>,
	Jonathan Tan <jonathantanmy@google.com>,
	Jeff Hostetler <jeffhost@microsoft.com>
Subject: Re: [PATCH v5 4/6] list-objects: filter objects in traverse_commit_list
Date: Thu, 30 Nov 2017 17:03:15 -0500	[thread overview]
Message-ID: <20171130220315.GA13784@sigill.intra.peff.net> (raw)
In-Reply-To: <21fbd685-2c96-91b9-700e-8902a6e99c08@jeffhostetler.com>

On Mon, Nov 27, 2017 at 02:39:43PM -0500, Jeff Hostetler wrote:

> On 11/22/2017 5:56 PM, Stefan Beller wrote:
> > On Tue, Nov 21, 2017 at 12:58 PM, Jeff Hostetler <git@jeffhostetler.com> wrote:
> > > +       assert(arg);
> > > +       assert(!unset);
> > 
> > I count 16 asserts in this patch. Is that really needed?
> > Either omit them or use BUG if we want to rely on user
> > bug reports when these conditions trigger, as assert is unreliable
> > due to its dependence on the NDEBUG flag.
> 
> Yes, there are a few asserts in the code.  Old habits....
> 
> I could remove some/all of them, but personally I feel they
> have merit and hint to the mindset of the author for future
> readers of the code.  Are there other opinions?

I think I'd prefer in general to see assertions remain in one form or
another, if only because of the documentation benefits you mention here.

I do think there's such a thing as too many asserts, but I don't think I
see that here. "Too many" would probably be something like asserting
things that are a normal part of the contract (so "assert(foo)" on
every pointer parameter coming in to make sure it's not NULL).

I thought at first that's what was happening with the ones quoted above,
but it's actually documenting that no, we do not support "--no-filter"
in opt_parse_list_objects_filter (which is really checking that we're in
sync with the PARSE_OPT_NONEG found elsewhere).

So arguably my confusion argues that this one ought to have a custom
message or a comment.

Of course, it also makes me wonder whether we ought to just support
--no-filter. Shouldn't it just set us back to FILTER_DISABLED?

> Personally, I think it might be awkward to keep repeating
> something like:
> 
>     if (!c)
>         BUG(msg);
> 
> Do we want to think about a macro that builds on BUG() and
> does the test?
> 
> Something like:
>     #define ASSERT_OR_BUG(c) do { if (!(c)) BUG("%s", #c); } while (0)

Yeah, I think that was where the other thread[1] led to. IMHO that's
probably what BUG_ON() ought to do (though personally I'm fine with just
continuing to use assert for simple cases).

I think we can sidestep the whole variadic-macros thing mentioned in
that thread since we don't take a custom message.

-Peff

[1] https://public-inbox.org/git/20171122223827.26773-1-sbeller@google.com/

  reply	other threads:[~2017-11-30 22:03 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-21 20:58 [PATCH v5 0/6] Partial clone part 1: object filtering Jeff Hostetler
2017-11-21 20:58 ` [PATCH v5 1/6] dir: allow exclusions from blob in addition to file Jeff Hostetler
2017-11-21 20:58 ` [PATCH v5 2/6] oidmap: add oidmap iterator methods Jeff Hostetler
2017-11-21 20:58 ` [PATCH v5 3/6] oidset: add iterator methods to oidset Jeff Hostetler
2017-11-21 20:58 ` [PATCH v5 4/6] list-objects: filter objects in traverse_commit_list Jeff Hostetler
2017-11-22 22:56   ` Stefan Beller
2017-11-27 19:39     ` Jeff Hostetler
2017-11-30 22:03       ` Jeff King [this message]
2017-11-21 20:58 ` [PATCH v5 5/6] rev-list: add list-objects filtering support Jeff Hostetler
2017-11-22 20:08   ` Jonathan Nieder
2017-11-29 14:51     ` Jeff Hostetler
2017-11-21 20:58 ` [PATCH v5 6/6] pack-objects: add list-objects filtering Jeff Hostetler
2017-11-22  1:37 ` [PATCH v5 0/6] Partial clone part 1: object filtering Jonathan Tan
2017-11-22  5:14   ` Junio C Hamano

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171130220315.GA13784@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@jeffhostetler.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jeffhost@microsoft.com \
    --cc=jonathantanmy@google.com \
    --cc=sbeller@google.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.
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 NNTP newsgroup(s).