All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Elijah Newren <newren@gmail.com>
Cc: Taylor Blau <me@ttaylorr.com>,
	 Elijah Newren via GitGitGadget <gitgitgadget@gmail.com>,
	 git@vger.kernel.org,  Dmitry Goncharov <dgoncharov@users.sf.net>
Subject: Re: [PATCH 2/2] merge-ort: fix slightly overzealous assertion for rename-to-self
Date: Thu, 13 Mar 2025 09:55:20 -0700	[thread overview]
Message-ID: <xmqqbju4q39j.fsf@gitster.g> (raw)
In-Reply-To: <CABPp-BF7iTvqKFvuOZ5wZ3vZADjCvB63iKR-4D5+WeTxnZGThg@mail.gmail.com> (Elijah Newren's message of "Wed, 12 Mar 2025 23:22:56 -0700")

Elijah Newren <newren@gmail.com> writes:

> On Wed, Mar 12, 2025 at 4:18 PM Junio C Hamano <gitster@pobox.com> wrote:
>>
>> Elijah Newren <newren@gmail.com> writes:
>>
>> > But it might be worth mentioning that having side-effects in
>> > assertions is a huge no-no, and I understand that when folks have to
>> > debug one of those (I had to in a separate project years ago which was
>> > kind of nasty), that they sometimes jump to the conclusion that
>> > assertions are bad.
>>
>> Yes, assert() invites such mistakes.  Why not avoid them when there
>> are better alternatives like "if (condition) BUG()"?
>
> I mean, I just gave my reasons above which you snipped out.  But if
> you feel it is important for folks to move away from assert(), would
> you like to see someone create a better alternative to assert, such as
> BUG_ON(condition), so that they have reason to want to switch?

You said "BUG_ON()" is better than "if (condition) BUG()", but I do
not see a reason why.  It also shares the same problem with assert()
if we make it honor NDEBUG.

Thanks.

  reply	other threads:[~2025-03-13 16:55 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-06 15:30 [PATCH 0/2] merge-ort: fix a crash in process_renames for a file transitively renamed to itself Elijah Newren via GitGitGadget
2025-03-06 15:30 ` [PATCH 1/2] t6423: add a testcase causing a failed assertion in process_renames Dmitry Goncharov via GitGitGadget
2025-03-06 15:30 ` [PATCH 2/2] merge-ort: fix slightly overzealous assertion for rename-to-self Elijah Newren via GitGitGadget
2025-03-12 22:00   ` Taylor Blau
2025-03-12 22:36     ` Elijah Newren
2025-03-12 23:18       ` Junio C Hamano
2025-03-13  6:22         ` Elijah Newren
2025-03-13 16:55           ` Junio C Hamano [this message]
2025-03-13 17:15             ` Elijah Newren
2025-03-13 18:34               ` Junio C Hamano
2025-03-14  0:24                 ` Elijah Newren

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=xmqqbju4q39j.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=dgoncharov@users.sf.net \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=me@ttaylorr.com \
    --cc=newren@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.