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=-4.0 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from am.mirrors.kernel.org (am.mirrors.kernel.org [IPv6:2604:1380:4601:e00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 6C7031F4B8 for ; Tue, 30 Apr 2024 01:47:45 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (2048-bit key; unprotected) header.d=jamesliu.io header.i=@jamesliu.io header.a=rsa-sha256 header.s=fm3 header.b=e3C/n2f2; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=MwcjiG/P; dkim-atps=neutral Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 78A251F22650 for ; Tue, 30 Apr 2024 01:47:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 55B7C53A7; Tue, 30 Apr 2024 01:47:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=jamesliu.io header.i=@jamesliu.io header.b="e3C/n2f2"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="MwcjiG/P" Received: from fout3-smtp.messagingengine.com (fout3-smtp.messagingengine.com [103.168.172.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AFE531843 for ; Tue, 30 Apr 2024 01:47:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.146 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714441653; cv=none; b=gPnKxNri5Qz1I+yOOaCXCeG3+M7NNT+DTzPdTUqQEDntpDD/6nLGx+J2WrM2bW1CJfDTLtB70U2G5y0I+g/ONtjaih4vw4J9VTZfzrcnipMTcynbPkYseVJepg3Q8RbAfcyv3EnlDVkVRvlmYzB0rXr6b1TlAVuYdMtEqxVlcQw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714441653; c=relaxed/simple; bh=GDMjkR9qrnDrHJpEhFLzG8xD7vKjd+bfYO+OGhE09AU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JPuT5V48uijODKhsqJFmLBQsWG7Govs2LkDnts9uyT9iY3F5xf8qgw/vukq+9HvQpR6cojYWE1iRbmBh+u6aPdH7j3Ksf06U5nTX/oV+eQ+FjLNcmn0fO+pPLPfCKai/aWRi1VlC0ZwrrkbxktWOZtxyLVBJfMPc8WLWfBf1r1M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=jamesliu.io; spf=pass smtp.mailfrom=jamesliu.io; dkim=pass (2048-bit key) header.d=jamesliu.io header.i=@jamesliu.io header.b=e3C/n2f2; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=MwcjiG/P; arc=none smtp.client-ip=103.168.172.146 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=jamesliu.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=jamesliu.io Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailfout.nyi.internal (Postfix) with ESMTP id C5D56138014F; Mon, 29 Apr 2024 21:47:30 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Mon, 29 Apr 2024 21:47:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jamesliu.io; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm3; t=1714441650; x= 1714528050; bh=x+trdz2FvbXPfqtQoCzsxozYLYVQsejbOm8EJDYEsw8=; b=e 3C/n2f2dOR0TLf9rdiZHkCfVWzOAPDs3SIRiEgUAYzN5da4USgMS9qAzOmCDQEcs EMyYfb0nmKnakV1eHFFCnhGWPvOmUlRf0E5FlAgOkihU2++d+RPkAUVu0d42iLqR 1/Rz4gmv0RIryh2QnTRxHPbHmc+VRwQJBCMvw1qcK6aGeMycQ6nPfjjW7ZqO+e6h jnaoQ/u3ulst2SS5xVgyBSzvIAp1gUXDjZ31CUJhh1O+QIHrjSGJd8A4vpgZIxxg JjLy6GEzDD7US1YaoENj/AS0r/lYaPA82uc4XqXOYMkhZ1w8RME63VrPxcMvsfok hPcZoi4SCAHiH4KcwKf4Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1714441650; x= 1714528050; bh=x+trdz2FvbXPfqtQoCzsxozYLYVQsejbOm8EJDYEsw8=; b=M wcjiG/PdIiJ1hfMz9uSjRoesNf4RxjdudYR0E1b6kmveBMYyu+PhY01fY3zsJMvD GtJYOIn2lSJp1WmjiLHipalFPQzs7OYRwTaskTxYZ9BoISLYndKXtdd9/5wS+HLR 4TqsymgbakO7/wklHIhL5Cb2mxgUNhjJbSNpvDApw2uP/xBLZupq/nhRc3nDjlVL uqhsTKexBX3QCdR+COIWA3t5NFvzqXlu3tqxkrNZmvFZfcxNNe7Jfszgcg4TUdWD jjr77PUnoUNN8lzyVJyABqlZeOgOc2xfim08NMQWO0B9ywQdzC16EMfYPJ+NHXQy GYdvhj9jiWAS9VDyusYMw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdduvddgheduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpeflrghmvghsucfnihhuuceojhgrmhgvshesjhgrmhgvshhl ihhurdhioheqnecuggftrfgrthhtvghrnhepleejtdeuudfgteegfeeiudehleeutedvhf euueeuheevleejkeelteetfeevhfejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghr rghmpehmrghilhhfrhhomhepjhgrmhgvshesjhgrmhgvshhlihhurdhioh X-ME-Proxy: Feedback-ID: i93f149ec:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 29 Apr 2024 21:47:29 -0400 (EDT) From: James Liu To: git@vger.kernel.org Cc: James Liu Subject: [PATCH v3 0/1] advice: add --no-advice global option Date: Tue, 30 Apr 2024 11:47:23 +1000 Message-ID: <20240430014724.83813-1-james@jamesliu.io> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240429010925.93205-1-james@jamesliu.io> References: <20240429010925.93205-1-james@jamesliu.io> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Hi, This is v3 of the patch to add a global --no-advice option for silencing all advice hints. The environment variable has been renamed to GIT_ADVICE and marked for internal use only, and the conditional in the advice_enabled() helper has been adjusted to use git_env_bool(). I explored the idea of adding another test to ensure the configuration is propagated to subprocesses correctly. This would use `git fetch --all` as the trigger, however it appears that advice is only printed when `fetch_one()` is invoked, which I don't think spawns any child processes. With that said, since this is a common pattern, I believe the existing additional test case is sufficient. Cheers, James James Liu (1): advice: add --no-advice global option Documentation/git.txt | 5 ++++- advice.c | 8 +++++++- environment.h | 7 +++++++ git.c | 6 +++++- t/t0018-advice.sh | 20 ++++++++++++++++++++ 5 files changed, 43 insertions(+), 3 deletions(-) Range-diff against v2: 1: 0f2ecb7862 ! 1: 55d5559586 advice: add --no-advice global option @@ Commit message Add a --no-advice global option to disable all advice hints from being displayed. This is independent of the toggles for individual advice - hints. + hints. Use an internal environment variable (GIT_ADVICE) to ensure this + configuration is propagated to the usage site, even if it executes in a + subprocess. Signed-off-by: James Liu @@ advice.c: void advise(const char *advice, ...) - int enabled = advice_setting[type].level != ADVICE_LEVEL_DISABLED; + int enabled; + -+ if (getenv(GIT_NO_ADVICE)) ++ if (!git_env_bool(GIT_ADVICE, 1)) + return 0; + + enabled = advice_setting[type].level != ADVICE_LEVEL_DISABLED; @@ advice.c: void advise(const char *advice, ...) ## environment.h ## @@ environment.h: const char *getenv_safe(struct strvec *argv, const char *name); - #define GIT_OPTIONAL_LOCKS_ENVIRONMENT "GIT_OPTIONAL_LOCKS" #define GIT_TEXT_DOMAIN_DIR_ENVIRONMENT "GIT_TEXTDOMAINDIR" #define GIT_ATTR_SOURCE_ENVIRONMENT "GIT_ATTR_SOURCE" -+#define GIT_NO_ADVICE "GIT_NO_ADVICE" ++/* ++ * Environment variable used to propagate the --no-advice global option to the ++ * advice_enabled() helper, even when run in a subprocess. ++ * This is an internal variable that should not be set by the user. ++ */ ++#define GIT_ADVICE "GIT_ADVICE" ++ /* * Environment variable used in handshaking the wire protocol. + * Contains a colon ':' separated list of keys with optional values ## git.c ## @@ git.c: const char git_usage_string[] = @@ git.c: static int handle_options(const char ***argv, int *argc, int *envchanged) if (envchanged) *envchanged = 1; + } else if (!strcmp(cmd, "--no-advice")) { -+ setenv(GIT_NO_ADVICE, "1", 1); ++ setenv(GIT_ADVICE, "0", 1); + if (envchanged) + *envchanged = 1; } else { -- 2.44.0