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: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by dcvr.yhbt.net (Postfix) with ESMTP id 202CC1F403 for ; Fri, 14 Oct 2022 20:27:54 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (1024-bit key; unprotected) header.d=pobox.com header.i=@pobox.com header.b="lcP40GG6"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231398AbiJNU1q (ORCPT ); Fri, 14 Oct 2022 16:27:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231350AbiJNU1n (ORCPT ); Fri, 14 Oct 2022 16:27:43 -0400 Received: from pb-smtp20.pobox.com (pb-smtp20.pobox.com [173.228.157.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 930975D701 for ; Fri, 14 Oct 2022 13:27:42 -0700 (PDT) Received: from pb-smtp20.pobox.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id 2A4961C444D; Fri, 14 Oct 2022 16:27:42 -0400 (EDT) (envelope-from junio@pobox.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=Hpyp4sh4VbrNJIY48R3ZqGrGCEuJ8Vg84TNv6Z +YAuY=; b=lcP40GG6HNtXTmkTa2oGZ20l5Qe7e71/wFML8NtFMrnwuHdXvG1pVb cr4GDY3GEF5GZ/2utoA9UgYxP7stELvVJyyySBEqTbZbdVycOtJ7CtOIu6d1fr14 +x60IBKoV3NWy8VqM8Aua8dP6h99zGue4nECtI9LCSTXEh9bd6auQ= Received: from pb-smtp20.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id 217021C444C; Fri, 14 Oct 2022 16:27:42 -0400 (EDT) (envelope-from junio@pobox.com) Received: from pobox.com (unknown [34.83.5.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp20.pobox.com (Postfix) with ESMTPSA id 52A881C444A; Fri, 14 Oct 2022 16:27:39 -0400 (EDT) (envelope-from junio@pobox.com) From: Junio C Hamano To: Jeff King Cc: =?utf-8?B?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , git@vger.kernel.org, =?utf-8?Q?Ren=C3=A9?= Scharfe Subject: Re: [PATCH 03/10] run-command API: add and use a run_command_l_opt() References: Date: Fri, 14 Oct 2022 13:27:38 -0700 In-Reply-To: (Jeff King's message of "Fri, 14 Oct 2022 16:03:39 -0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: A5C92276-4BFE-11ED-BFDA-C2DA088D43B2-77302942!pb-smtp20.pobox.com Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Jeff King writes: > On Fri, Oct 14, 2022 at 11:40:27AM -0700, Junio C Hamano wrote: > >> > @@ -862,11 +858,11 @@ static void write_refspec_config(const char *src_ref_prefix, >> > >> > static void dissociate_from_references(void) >> > { >> > - static const char* argv[] = { "repack", "-a", "-d", NULL }; >> >> Good to see that this one in a wrong scope can now go away. > > It definitely is broader scope than is necessary. I wonder if it makes > things easier to read, though, the way we would sometimes hoist things > out of a function into a static-global to make them more obvious. I > dunno. Didn't think about it, but it is a worthy point to make. Unlike the call to l_opt() buried inside a conditional, it makes it stand out that what we see upfront is one of the commands the function will run. It is especially valuable when a function is almost exclusively about running a single command, but then we will have a single call to l_opt() without much preparations or clean-ups around it, so the visual noise that detracts our eyes away from the actual commands may not be all that bad, though. >> > char *alternates = git_pathdup("objects/info/alternates"); >> > >> > if (!access(alternates, F_OK)) { >> > - if (run_command_v_opt(argv, RUN_GIT_CMD|RUN_COMMAND_NO_STDIN)) >> > + if (run_command_l_opt(RUN_GIT_CMD|RUN_COMMAND_NO_STDIN, >> > + "repack", "-a", "-d", NULL)) >> > die(_("cannot repack to clean up")); > > I just happened to notice in this one there is a weird extra space > before "-a". Yeah, good eyes. Thanks.