From mboxrd@z Thu Jan 1 00:00:00 1970 From: Junio C Hamano Subject: Re: [PATCH] Speedup scanning for excluded files. Date: Mon, 29 Oct 2007 17:00:42 -0700 Message-ID: <7vzly1sc7p.fsf@gitster.siamese.dyndns.org> References: <200710290845.26727.lars@trolltech.com> <20071029080234.GA22826@artemis.corp> <200710290959.32538.lars@trolltech.com> <118833cc0710291559kbd874a8o8111b9495090ef27@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: "Lars Knoll" , git@vger.kernel.org, "Pierre Habouzit" , "Junio C Hamano" To: "Morten Welinder" X-From: git-owner@vger.kernel.org Tue Oct 30 01:01:07 2007 Return-path: Envelope-to: gcvg-git-2@gmane.org Received: from vger.kernel.org ([209.132.176.167]) by lo.gmane.org with esmtp (Exim 4.50) id 1ImeXY-0005S4-E6 for gcvg-git-2@gmane.org; Tue, 30 Oct 2007 01:01:04 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752194AbXJ3AAv (ORCPT ); Mon, 29 Oct 2007 20:00:51 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751361AbXJ3AAv (ORCPT ); Mon, 29 Oct 2007 20:00:51 -0400 Received: from sceptre.pobox.com ([207.106.133.20]:60865 "EHLO sceptre.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750875AbXJ3AAu (ORCPT ); Mon, 29 Oct 2007 20:00:50 -0400 Received: from sceptre (localhost.localdomain [127.0.0.1]) by sceptre.pobox.com (Postfix) with ESMTP id 628F02EF; Mon, 29 Oct 2007 20:01:11 -0400 (EDT) Received: from pobox.com (ip68-225-240-77.oc.oc.cox.net [68.225.240.77]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by sceptre.sasl.smtp.pobox.com (Postfix) with ESMTP id C455B9020F; Mon, 29 Oct 2007 20:01:05 -0400 (EDT) In-Reply-To: <118833cc0710291559kbd874a8o8111b9495090ef27@mail.gmail.com> (Morten Welinder's message of "Mon, 29 Oct 2007 18:59:00 -0400") User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) Sender: git-owner@vger.kernel.org Precedence: bulk X-Mailing-List: git@vger.kernel.org Archived-At: "Morten Welinder" writes: >> + } else if (x->flags & EXC_FLAG_ENDSWITH) { >> + if (!strcmp(exclude + 1, pathname + pathlen -x->patternlen + 1)) > > Is there some guarantee that the result of that subtraction is still within > the string? Good eyes. If pattern is "*.exe", patternlen is 5, and strcmp wants to compare 4 chars, so pathlen is better be at least that long, and we do allow that pattern to match a hidden file ".exe". Like this? if (x->patternlen - 1 <= pathlen && !strcmp(exclude + 1, pathname + pathlen - x->patternlen + 1)) return to_exclude;