From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS53758 23.128.96.0/24 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id 77C891F8C8 for ; Fri, 24 Sep 2021 12:04:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244801AbhIXMGM (ORCPT ); Fri, 24 Sep 2021 08:06:12 -0400 Received: from h4.fbrelay.privateemail.com ([131.153.2.45]:47001 "EHLO h4.fbrelay.privateemail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239965AbhIXMGL (ORCPT ); Fri, 24 Sep 2021 08:06:11 -0400 Received: from MTA-08-3.privateemail.com (mta-08-1.privateemail.com [68.65.122.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by h3.fbrelay.privateemail.com (Postfix) with ESMTPS id 6558F80514 for ; Fri, 24 Sep 2021 08:04:37 -0400 (EDT) Received: from mta-08.privateemail.com (localhost [127.0.0.1]) by mta-08.privateemail.com (Postfix) with ESMTP id 8FA3C18000A5; Fri, 24 Sep 2021 08:04:36 -0400 (EDT) Received: from [192.168.0.46] (unknown [10.20.151.233]) by mta-08.privateemail.com (Postfix) with ESMTPA id C25BF18000A4; Fri, 24 Sep 2021 08:04:35 -0400 (EDT) Date: Fri, 24 Sep 2021 08:04:29 -0400 From: Hamza Mahfooz Subject: Re: [PATCH v7 1/2] grep: refactor next_match() and match_one_pattern() for external use To: Junio C Hamano Cc: git@vger.kernel.org, Jeff King , Eric Sunshine Message-Id: In-Reply-To: References: <20210921211324.1426938-1-someguy@effective-light.com> X-Mailer: geary/40.0 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Thu, Sep 23 2021 at 10:25:28 AM -0700, Junio C Hamano wrote: > But how would the new caller that points "bol" at middle of a line > make sure that we are looking at the right kind of header? If the > pattern p is set to match only for an author line, the first call > with "bol" set to the true beginning of the line will correctly > reject a "committer" header, but because you lost the sanity check > above, the second and subsequent one will go ahead and scan for the > pattern p on the line, even if p->field asks for author line and the > line records the committer. You'd end up finding a commit object > that is committed by (but not authored by) the person when you are > looking for a commit that was authored by somebody, no? > > If you ask for commits by somebody (e.g. "--author=Hazma") with an > output format that shows both the author and the committer > (e.g. "log --pretty=fuller"), wouldn't your "hit coloring" code > show Hazma on the committer name as a grep hit, too? Actually, this issue doesn't arise because I filter away the irrelevant (header) patterns in grep_next_match(). However, maybe it's a better idea to handle that in match_one_pattern().