From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fout-a8-smtp.messagingengine.com (fout-a8-smtp.messagingengine.com [103.168.172.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B4567338593 for ; Tue, 28 Jul 2026 16:22:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.151 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785255766; cv=none; b=Y2FKY8yDmaBN71AmcWOqM5V51JlpwP+MtK6u0VCqm55MlxiebKxBv1WkAS1HDNHHeyyJRKeG5oDxP7CWgaR+hHZJwnfYANeWuAMAuL+zZ+Tc70D3mNUVtW+ONIC3mP7fInjQ88BNHfgVPhC6x9Dxzds+cu8G5EaOZwPIMkHR/ZY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785255766; c=relaxed/simple; bh=GxDtKsqQ7lAPVD4nGuVwVp+21mExUfNe4TcivZRXvuk=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=JIQRLzC9bFlclZgaEMdCTmVjinWKbvnjHW9k/bbikA1IyOpR7x4ibYH18tFD0FcXBdk44Z7TY8sgKjzmgkdJngBVio72zQmK3FPUaG0DlYczB8ktTqpkpY16VBMRo3p1e7JMvjNUwBmmUuhBcgoeOxUoM8LtTcmBIONz50vpql8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com; spf=pass smtp.mailfrom=pobox.com; dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b=WTSmAbJU; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=n1DEAPjG; arc=none smtp.client-ip=103.168.172.151 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pobox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b="WTSmAbJU"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="n1DEAPjG" Received: from phl-compute-11.internal (phl-compute-11.internal [10.202.2.51]) by mailfout.phl.internal (Postfix) with ESMTP id C9E8EEC0384; Tue, 28 Jul 2026 12:22:43 -0400 (EDT) Received: from phl-frontend-01 ([10.202.2.160]) by phl-compute-11.internal (MEProxy); Tue, 28 Jul 2026 12:22:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pobox.com; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1785255763; x=1785342163; bh=OGvQDzSa8M bMOAhE3iwYWimYjihYHY/f9E8O2kNY1Zc=; b=WTSmAbJU4UxV9+2KrLSmQxESDU uKKThqkfCg8hqP7W0prpHnvOsGmj8an6Rm04n0ZmXbHL7tj1OiokyiVGDCZAN/Ic MY1wFWfSArWwn9Kv5QcliwfGw4+eP8gx8A29cwJUuZDeaUctgAcEv2Fn2ZO5MXYB 39QhZD9pKhVhv2FUSvI8emWmhvmRR6Dpya5RxrNmRB+7N0dPvfMvJbROhR1m/Gy3 cULFs+rp7SR+X+hEKjHlA6c3rRLtoYlw50Q2NdlwzMmiCsc+vT2pMDWIVCxyXv/P AmU4tVRjYJhDd6Spoa/ZTOTp9TmcuUWSDEJAG68qH4bEHascJ3uWW1pqeNjA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1785255763; x=1785342163; bh=OGvQDzSa8Mb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ZZ2OV3ldIZdpRVjHNGN1FwSHZSw X-ME-Proxy: Feedback-ID: if26b431b:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 28 Jul 2026 12:22:43 -0400 (EDT) From: Junio C Hamano To: Jeff King Cc: git@vger.kernel.org Subject: Re: [PATCH] diff-lib: add idx/tree sanity check to oneway_diff In-Reply-To: <20260728151458.GB41931@coredump.intra.peff.net> (Jeff King's message of "Tue, 28 Jul 2026 11:14:58 -0400") References: <20260726084550.GC2366012@coredump.intra.peff.net> <20260726084705.GB3529698@coredump.intra.peff.net> <20260727093912.GA591426@coredump.intra.peff.net> <20260728151458.GB41931@coredump.intra.peff.net> Date: Tue, 28 Jul 2026 09:22:42 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Jeff King writes: >> We could help humans that the BUG is not expected to fire and only >> to help static analysis by a crafted message, perhaps? >> >> if (!idx && !tree) >> BUG("Hey, Coverity, this does not happen"); > > If we are helping humans we can probably afford to be a little more > eloquent. ;) I do not mind eloquence but does the comment clearly say this is primarily for unconfusing static analyzers? My first reaction to the message was "OK, you explained very well why this condition would never happen, but then why do you need to check and BUG() on it???" But I guess the point is a future modification may invalidate this, in which case I agree with the comment. If it is hard for static analysers to get it right, it probably is equally difficult to grok for AI agents many people seem to be using to draft their changes these days ;-). > + /* > + * We should only see a NULL idx when the entry was present in the tree > + * but deleted in the idx. In which case it should be impossible > + * that a NULL tree was passed in (there would have been no entry at > + * all) or that we got a df conflict above (you need a directory and a > + * file to get such a conflict, which implies both sides are present). > + */ > + if (!idx && !tree) > + BUG("oneway_diff with neither idx nor tree"); > + > if (revs->diffopt.prefix && > strncmp((idx ? idx : tree)->name, revs->diffopt.prefix, > revs->diffopt.prefix_length))