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.8 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,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 A19611F452 for ; Thu, 30 Mar 2023 18:25:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229768AbjC3SZG (ORCPT ); Thu, 30 Mar 2023 14:25:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231228AbjC3SZF (ORCPT ); Thu, 30 Mar 2023 14:25:05 -0400 Received: from cloud.peff.net (cloud.peff.net [104.130.231.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DBF35FEB for ; Thu, 30 Mar 2023 11:25:03 -0700 (PDT) Received: (qmail 30030 invoked by uid 109); 30 Mar 2023 18:25:02 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Thu, 30 Mar 2023 18:25:02 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 19950 invoked by uid 111); 30 Mar 2023 18:25:02 -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; Thu, 30 Mar 2023 14:25:02 -0400 Authentication-Results: peff.net; auth=none Date: Thu, 30 Mar 2023 14:25:02 -0400 From: Jeff King To: Junio C Hamano Cc: =?utf-8?Q?=C3=98ystein?= Walle , git@vger.kernel.org Subject: Re: [PATCH 2/2] branch, for-each-ref: add option to omit empty lines Message-ID: <20230330182502.GB3286761@coredump.intra.peff.net> References: <20230330112133.4437-1-oystwa@gmail.com> <20230330112133.4437-3-oystwa@gmail.com> 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 Thu, Mar 30, 2023 at 08:54:35AM -0700, Junio C Hamano wrote: > * now we care if output is empty anyway, perhaps we can optimize > out fwrite() too, perhaps with something like > > if (output.len || !omit_empty) > printf("%.*s\n", output.len, output.buf); > > perhaps? > > I am not sure about the latter, but we tend to use "%.*s" liberally > when we could use fwrite() in our codebase for brevity, so ... I think it would be a mistake here, as you can use "%00" in the format to include a NUL in the output. (The rest of your review seemed quite sensible to me, and I like the idea of the omit-empty option in general). -Peff