From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by dcvr.yhbt.net (Postfix) with ESMTP id A1B381F428 for ; Wed, 15 Mar 2023 19:45:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231794AbjCOTpM (ORCPT ); Wed, 15 Mar 2023 15:45:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233037AbjCOTpC (ORCPT ); Wed, 15 Mar 2023 15:45:02 -0400 Received: from cloud.peff.net (cloud.peff.net [104.130.231.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E60E56EA7 for ; Wed, 15 Mar 2023 12:45:00 -0700 (PDT) Received: (qmail 20009 invoked by uid 109); 15 Mar 2023 19:45:00 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Wed, 15 Mar 2023 19:45:00 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 3838 invoked by uid 111); 15 Mar 2023 19:44:59 -0000 Received: from coredump.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.2) by peff.net (qpsmtpd/0.94) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPS; Wed, 15 Mar 2023 15:44:59 -0400 Authentication-Results: peff.net; auth=none Date: Wed, 15 Mar 2023 15:44:59 -0400 From: Jeff King To: Junio C Hamano Cc: Derrick Stolee via GitGitGadget , git@vger.kernel.org, me@ttaylorr.com, vdye@github.com, Derrick Stolee Subject: Re: [PATCH v2 1/8] for-each-ref: add --stdin option Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Wed, Mar 15, 2023 at 12:24:18PM -0700, Junio C Hamano wrote: > Jeff King writes: > > > ... we may > > want some kind of "literal" mode, that takes in a list of refs rather > > than a list of patterns, and does a sorted-merge with the list of > > available refs (or uses a hash table, I guess, but for-each-ref also > > tries to avoid even being linear in the total number of refs, so you'd > > still want to find the lowest/highest to bound the iteration). > > Exactly. > > I actually was wondering if "literal" mode can just take a list of > , and when a is not a refname, use it as if it > were. I.e. %(refname) would parrot it, while %(refname:short) would > not shorten and still parrot it, if the is 73876f4861c, but > something like %(subject) would still work. Yeah, I think that would nicely solve the quadratic issue _and_ the "we are stuck using only ref tips" issue. I like it. > For that, I suspect ref-filter.c::filter_refs() would need to learn > a different kind fo finter->kind that iterates over the literal > "refs" that was fed from the standard input, instead of calling > for_each_fullref_in() for the given hierarchy, but the new iterator > should be able to reuse the ref_filter_hander() for the heavy > lifting. Yeah, that sounds about right from my recollection of the code. I suspect there may be other sharp edges (e.g., asking for %(upstream) isn't meaningful for a non-ref). But softening those is actually something I think we want to do in the long run, as it helps with the long-term goal of sharing pretty-printing code between ref-filter, cat-file, and pretty.c. -Peff