From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fout-b7-smtp.messagingengine.com (fout-b7-smtp.messagingengine.com [202.12.124.150]) (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 3CDA33FB067 for ; Mon, 31 Aug 2026 18:26:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.150 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788200804; cv=none; b=VhlFRt+M0bZ0OtrM9pYZUvqMhrZlqjLLHABy3SfZhb/hylzo7HdUE5IAfY6fuy3D9wJiQ+qJtWyHvGqZJe6gcPQlu9Uq40RVSk4LvNMsuBUy7CxdxdBTDYpVrhQRhYc8OYa6EAKDZ7w2XIkbN7vg0WjHU4DATJFTqJI40poueiQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788200804; c=relaxed/simple; bh=q1RuJk1mV2/KNX7KyGpOvAJPFlJgWeGTqla7W2Y0wns=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=lg/kGuxpA7BNfAXKmtRa17p8PecYMHRayZ7xRY7ecC+bKrmvXiazQaXkL2vSdtlAosY5f3BbCw3BD4KGApzTFczofkjTBL1SEFfx4lmIyr4CqVEiaxofmg8kGgsez0q/VJg5Cs1F0bzqFumgjKjMCU1UW/+9hUchhBMOgCOBcJI= 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=jcyyBUIe; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=NNIUxMRi; arc=none smtp.client-ip=202.12.124.150 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="jcyyBUIe"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="NNIUxMRi" Received: from phl-compute-10.internal (phl-compute-10.internal [10.202.2.50]) by mailfout.stl.internal (Postfix) with ESMTP id 22C8E1D000FA; Mon, 31 Aug 2026 14:26:41 -0400 (EDT) Received: from phl-frontend-01 ([10.202.2.160]) by phl-compute-10.internal (MEProxy); Mon, 31 Aug 2026 14:26:41 -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=fm2; t=1788200800; x=1788287200; bh=4KZsALtCae XIERMY5XSXc6/ZgIL04wSnoAa3twO0SEs=; b=jcyyBUIe8kBPdBLBQEJZkMEIDR qlVf4gnosBYohUEWxbRsmhvIGtIMpfTFIzBC827+IANLzIneOHs6XeqilWrExeA0 tJJcASeDwMvMp5fWT5dp7X4QoSAWXl7AA/c29/QPc0nnIlwMv+zxKodBpfxbD5Y+ P7P7uScv6698UqQUbv1Nao6jM8VGXQlGaNpx+YQ9uDjINfjhaJDc0KPizpv/ZOd5 292JRXqzbofWrbp98VWdc9g1L2zJd4CSWDm3678fTOHdT3y4p8iEtZe4OkCAiML5 wtD1uvEZ4cWT79Wt4S8ID3Nn31KozWSpyzrZJ0pR8vbiXdU08nHhRk3Q1PQg== 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=fm3; t= 1788200800; x=1788287200; bh=4KZsALtCaeXIERMY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ZSxcrwFbgVuxsN/Uzej3b/WHt/oyNdw X-ME-Proxy: Feedback-ID: if26b431b:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 31 Aug 2026 14:26:40 -0400 (EDT) From: Junio C Hamano To: Diogo Castro Cc: Diogo Castro , Diogo Castro via GitGitGadget , "git@vger.kernel.org" , Thomas Haller , Jeff King Subject: Re: [PATCH] dir: fix negative pathspecs in 'git ls-files' and 'git add' In-Reply-To: (Diogo Castro's message of "Mon, 31 Aug 2026 15:30:22 +0100") References: Date: Mon, 31 Aug 2026 11:26:39 -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 Diogo Castro writes: > My point was that computing the common prefix across both positive > *and* negative pathspecs would not improve performance, and might > actually make it worse. OK. Then that points at the right solution. Ignore negative ones when finding what the common prefix is, strip it only from positive ones to reduce the width of the traversal to come up with the list of possible match candidates, and match them as full paths against the negative ones to cull "within the positive set but is excluded" paths, and the posted patch looks good. I still wonder if we need different implementation when we have many more negative patterns than the positive ones. In such a case, the stage to filter paths that matched one positive pattern by finding matches with a negative pattern among many of them, which may benefit from having a similar common prefix (among negative patterns) optimization, but that is a separate topic. Thanks.