From patchwork Tue Jan 9 15:29:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Rub=C3=A9n_Justo?= X-Patchwork-Id: 13515009 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 75B9E39FDC for ; Tue, 9 Jan 2024 15:29:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TrXFmt9p" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-40e52ebd640so3683885e9.3 for ; Tue, 09 Jan 2024 07:29:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704814176; x=1705418976; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:references:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=bikIPW2eO+xFrllwHwwMWp1LGn+Cp38w2f7xVcpjesg=; b=TrXFmt9pfMOIbFFh//Gdf5sHKz2li9ntEjFzsCyp/PJXWkML7QNV7kNmjrqPL8e83F yHn4eieNlwHgjA4sK0ryDOdDUzEzqL0f4DKOLPj3GnoRl3NbTW1TIDqXH55Cgdna8VZY /vYXj4G+j7XOOb0ZnhqqDSk3k5u5mcQ5CfolxLGVUuGtVr9GCctxckK+xbyuPVt4UqVB 3/yCM8myR5w5cVGQ9gQ2UqR2umINyg3iDn2FQq+1iLeDImuRsgRMoW/ARPKUrSXXJahN 72EhW7uJdwUoNLjGtR05DOFDi579pNKX9jRdFpZksQsPj1QBnUc7MA/+40Y2CKZjheww OutA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704814176; x=1705418976; h=content-transfer-encoding:in-reply-to:references:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=bikIPW2eO+xFrllwHwwMWp1LGn+Cp38w2f7xVcpjesg=; b=qBu+ktZ+0c+KW5oZZqT09KFY89icismEp2WzGJzB6GI7oD3vGbs8TGsZCImzSx7IR3 PMdg7AbDffyrhBVu2Q8WVIRM0BDjctdpwyuSIlGXeHox/k/VVOMM0dP9eWdE8Uj/1w2M q2TvM64UiploYslo71rZZIGI0yShkqEOWY2UlOdjsidxQdAaurUioWyQV2mGKx3lEPLW V8vSGPz/1am6T6hQjiblLxfZTVQAxT3Dfvru4l+AtUCsQ2oP4VS7tGB3p4zF3k4Suj4q vy71UUcjiLkaZZnoaEX+Uq6j+JI6nsgiuHEfkOWbCEo4Ta8v8eWIG61llu9OFg+QPGdL Zrew== X-Gm-Message-State: AOJu0Yx1jFG40/pLlTObRIAS/ezzraDw8ojg1cObJwHgWo5pNeEGQO2p FdHliS4rLAunJJpZCMhZVsHwsr/MZt4= X-Google-Smtp-Source: AGHT+IHgBfO3Eer/wgjcw3Hm94tKShUe+ULe5yz0WBarbOhd3S0N7Gue+mpmd2i7aK3r+CcWymOHSg== X-Received: by 2002:a05:600c:1d24:b0:40d:5c0d:1e3f with SMTP id l36-20020a05600c1d2400b0040d5c0d1e3fmr2999885wms.84.1704814176571; Tue, 09 Jan 2024 07:29:36 -0800 (PST) Received: from gmail.com (228.red-88-13-173.dynamicip.rima-tde.net. [88.13.173.228]) by smtp.gmail.com with ESMTPSA id i11-20020a05600c354b00b0040e47dc2e8fsm4025906wmq.6.2024.01.09.07.29.35 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 09 Jan 2024 07:29:36 -0800 (PST) Message-ID: Date: Tue, 9 Jan 2024 16:29:30 +0100 Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 1/3] t/test-tool: usage description Content-Language: en-US From: =?utf-8?q?Rub=C3=A9n_Justo?= To: Git List References: <7c68392c-af2f-4999-ae64-63221bf7833a@gmail.com> In-Reply-To: <7c68392c-af2f-4999-ae64-63221bf7833a@gmail.com> Even though this is an internal tool, let's keep the usage description correct and well organized. Signed-off-by: Rubén Justo --- t/helper/test-tool.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/helper/test-tool.c b/t/helper/test-tool.c index 37ba996539..d9f57c20db 100644 --- a/t/helper/test-tool.c +++ b/t/helper/test-tool.c @@ -5,7 +5,7 @@ #include "parse-options.h" static const char * const test_tool_usage[] = { - "test-tool [-C ] ...]]", + "test-tool [-C ] [...]]", NULL }; @@ -100,7 +100,7 @@ static NORETURN void die_usage(void) { size_t i; - fprintf(stderr, "usage: test-tool [args]\n"); + fprintf(stderr, "usage: %s\n", test_tool_usage[0]); for (i = 0; i < ARRAY_SIZE(cmds); i++) fprintf(stderr, " %s\n", cmds[i].name); exit(128); From patchwork Tue Jan 9 15:29:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Rub=C3=A9n_Justo?= X-Patchwork-Id: 13515010 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E255239FDD for ; Tue, 9 Jan 2024 15:30:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="D1ey1n7i" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-336c9acec03so2961452f8f.2 for ; Tue, 09 Jan 2024 07:30:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704814200; x=1705419000; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:references:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=PXa0jTBQcwka8heBNRg43HNBcslFt5tnihJBq9C9ZA4=; b=D1ey1n7iHqqxbBCHKtFpploxENJmD3Zna4/McjE/HEDVTbzrOydQ91RhzgKfvI/xPy Zw5aKrj+3koCb0nlXii0mYJxUEj+u2wUz82eBMko93TB/QSAf4rBlkHD9aXofTW2LSEb ptfcP+uxp0hW5ggNs7s+nysq24qWL+SD2oZs/Mp7Wo2x4zDF+8PYRCg6GNjAtHqvU+2z F3Feu+AuHcQrqkIJzIIji5mNBYV2jwZzibh7/wA1SYGj0rZEKW0zPpFfA2+TQYI9/OeA H7oh9la5xLB9cG7SHg0O9DnEe1off8TA1HyApuV81oebHh4o6cQJnqgnmDDV19reGr2x uybA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704814200; x=1705419000; h=content-transfer-encoding:in-reply-to:references:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=PXa0jTBQcwka8heBNRg43HNBcslFt5tnihJBq9C9ZA4=; b=fIIctHgon9YBJ9FRk8lGtS/043Km6jKGVbZgXJ0xgEFE+m2JOHcc64r6tkBR6IeQCJ ib7tMQS0gtgZmHwUUGOh5rdNN8FoqADe8TJmxj9pC38Kl6uAK9LDTuudMVBwZGG6cEJ1 CJyBpuM3llPyOIrTCuwt8tZK0UVeBKSaXFPvEny8yK7ZfNKFP4aTTyAE0X8Sg9nyoZJ0 hAs8bLub2JqSkDP1ebBsB1Qh0Hnw7O67/fWR+FId2eQ/mYbeRwP78OvdNVq16FZfKtAP SvWxEw72OnAYnStW1RuWMzAT1DJn6X+E2/38GKIyWXQYPU7LOvqcv47Ryaj5TrduecsH h0Rg== X-Gm-Message-State: AOJu0Yye4JS9GWWYj57srQXnQ8G13h6n7jFXkAFaHo7v4y9Mr6cwRsug wUJ+VJtVFCJ4fLzcNAvbkuBONuvK1zU= X-Google-Smtp-Source: AGHT+IEdoNOaihmal60AhFQntHSMUr4vKyBx0tpMyKvvLwRbbqEn0AtayT7iGWOlGF5cxJjJ87Y/Jw== X-Received: by 2002:a05:600c:2116:b0:40e:4864:d97 with SMTP id u22-20020a05600c211600b0040e48640d97mr1388424wml.64.1704814200026; Tue, 09 Jan 2024 07:30:00 -0800 (PST) Received: from gmail.com (228.red-88-13-173.dynamicip.rima-tde.net. [88.13.173.228]) by smtp.gmail.com with ESMTPSA id i11-20020a05600c354b00b0040e47dc2e8fsm4025906wmq.6.2024.01.09.07.29.57 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 09 Jan 2024 07:29:59 -0800 (PST) Message-ID: <6a4d6a56-ab6f-4557-a5a3-1713f57cbfc9@gmail.com> Date: Tue, 9 Jan 2024 16:29:57 +0100 Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 2/3] t/test-tool: handle -c = arguments Content-Language: en-US From: =?utf-8?q?Rub=C3=A9n_Justo?= To: Git List References: <7c68392c-af2f-4999-ae64-63221bf7833a@gmail.com> In-Reply-To: <7c68392c-af2f-4999-ae64-63221bf7833a@gmail.com> Soon we're going to need to pass configuration values to a command in test-tool. Let's teach test-tool to take config values via command line arguments. Signed-off-by: Rubén Justo --- t/helper/test-tool.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/t/helper/test-tool.c b/t/helper/test-tool.c index d9f57c20db..7eba4ec9ab 100644 --- a/t/helper/test-tool.c +++ b/t/helper/test-tool.c @@ -3,9 +3,10 @@ #include "test-tool-utils.h" #include "trace2.h" #include "parse-options.h" +#include "config.h" static const char * const test_tool_usage[] = { - "test-tool [-C ] [...]]", + "test-tool [-C ] [-c =] [...]", NULL }; @@ -106,6 +107,13 @@ static NORETURN void die_usage(void) exit(128); } +static int parse_config_option(const struct option *opt, const char *arg, + int unset) +{ + git_config_push_parameter(arg); + return 0; +} + int cmd_main(int argc, const char **argv) { int i; @@ -113,6 +121,9 @@ int cmd_main(int argc, const char **argv) struct option options[] = { OPT_STRING('C', NULL, &working_directory, "directory", "change the working directory"), + OPT_CALLBACK('c', NULL, NULL, "=", + "pass a configuration parameter to the command", + parse_config_option), OPT_END() }; From patchwork Tue Jan 9 15:30:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Rub=C3=A9n_Justo?= X-Patchwork-Id: 13515011 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A3B039AD5 for ; Tue, 9 Jan 2024 15:30:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="O6HUIIov" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-40e43e489e4so32180725e9.1 for ; Tue, 09 Jan 2024 07:30:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704814219; x=1705419019; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:references:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=ni2J1M9hC6jz+U0GSHk4fPv7xsSribPCM2g9vFdIb1Y=; b=O6HUIIovEe3DyvX8BkGyWK2cV7OPEWj+cf/+MtEjzn5m/hGfOV8D+oeFaJvwA3jVXQ 3PGNo6YGWzS57gvqHxzsRTuezs+x0Jf1WFkNQnr1mLH+C99uwr8HhjerWFofREvEk2Le YCpHYpihfcNYRacIP3slLE6P6ChOGzwdVp5XqMF198F1HsNjRJ/7W8OAF8ULZYoZkAMQ 1TCwTdaZWSEAHT51lEebmNVNK2Ez20XYDVJYBZZYkFoEJqdg+0jWJo73HxGApHgc2cFJ tzC4VMcFYcJdwO07lqYq/gzmBvT+bKqfgsydv4k2DIrNtqpv6NyV/8+18qEFvYZ2MOPX 0U9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704814219; x=1705419019; h=content-transfer-encoding:in-reply-to:references:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ni2J1M9hC6jz+U0GSHk4fPv7xsSribPCM2g9vFdIb1Y=; b=OIQekNg1RZTk4v9qa7s3GDTqrm+zXXDOA2WjbZmIQYEx+GGTigeQmWMl+DBiuOfIR6 vEG9wxCGOFLjDHfLbLS9ZxZKdREukYT0usU6fK7TxctCLX94Vyn/4a5XNcHLlcY1HOjk SrwiIiMD1gyTnm4fj7EtdPm6U8yBkYSiWTx9J59AEapu/0ojtI8gATaocvzUr0/BI2OB RBmj4RKIJautpBMUSbaB3Z524HPlN3vwd9mNozVDpjMtB2+Fr7KRUSK2sKN1XqWpOuV8 foeSrmqkY/eo5qXCVQgdTGi4p5xBGLzjL5t/XDe9Zp5eSGLbMeYSuOFaifvCr4oVKoNS yh8w== X-Gm-Message-State: AOJu0Ywa3LpzrTW7znnprpbNe/OZvSdTKNjuaxyb1rHC8CPrNbBQHxlB 9tNnC60x+bve/H3oshJuQ4H72d8rTlU= X-Google-Smtp-Source: AGHT+IFOx7TzjTLN01mUhb80GLQrO6NsjA54O/HHSHIjey4+jum1Q7XK2aatcWMfM3vErgfJgv0dnw== X-Received: by 2002:a05:600c:1c20:b0:40e:53f8:5242 with SMTP id j32-20020a05600c1c2000b0040e53f85242mr45043wms.72.1704814219242; Tue, 09 Jan 2024 07:30:19 -0800 (PST) Received: from gmail.com (228.red-88-13-173.dynamicip.rima-tde.net. [88.13.173.228]) by smtp.gmail.com with ESMTPSA id i11-20020a05600c354b00b0040e47dc2e8fsm4025906wmq.6.2024.01.09.07.30.16 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 09 Jan 2024 07:30:18 -0800 (PST) Message-ID: Date: Tue, 9 Jan 2024 16:30:16 +0100 Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 3/3] advice: allow disabling the automatic hint in advise_if_enabled() Content-Language: en-US From: =?utf-8?q?Rub=C3=A9n_Justo?= To: Git List References: <7c68392c-af2f-4999-ae64-63221bf7833a@gmail.com> In-Reply-To: <7c68392c-af2f-4999-ae64-63221bf7833a@gmail.com> Using advise_if_enabled() to display an advice will automatically include instructions on how to disable the advice, along with the main advice: hint: use --reapply-cherry-picks to include skipped commits hint: Disable this message with "git config advice.skippedCherryPicks false" This can become distracting or noisy over time, while the user may still want to receive the main advice. Let's have a switch to allow disabling this automatic advice. Signed-off-by: Rubén Justo --- advice.c | 3 ++- advice.h | 3 ++- t/t0018-advice.sh | 8 ++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/advice.c b/advice.c index 50c79443ba..fa203f8806 100644 --- a/advice.c +++ b/advice.c @@ -79,6 +79,7 @@ static struct { [ADVICE_UPDATE_SPARSE_PATH] = { "updateSparsePath", 1 }, [ADVICE_WAITING_FOR_EDITOR] = { "waitingForEditor", 1 }, [ADVICE_WORKTREE_ADD_ORPHAN] = { "worktreeAddOrphan", 1 }, + [ADVICE_ADVICE_OFF] = { "adviceOff", 1 }, }; static const char turn_off_instructions[] = @@ -93,7 +94,7 @@ static void vadvise(const char *advice, int display_instructions, strbuf_vaddf(&buf, advice, params); - if (display_instructions) + if (display_instructions && advice_enabled(ADVICE_ADVICE_OFF)) strbuf_addf(&buf, turn_off_instructions, key); for (cp = buf.buf; *cp; cp = np) { diff --git a/advice.h b/advice.h index 2affbe1426..1f2eef034e 100644 --- a/advice.h +++ b/advice.h @@ -10,7 +10,7 @@ struct string_list; * Add the new config variable to Documentation/config/advice.txt. * Call advise_if_enabled to print your advice. */ - enum advice_type { +enum advice_type { ADVICE_ADD_EMBEDDED_REPO, ADVICE_ADD_EMPTY_PATHSPEC, ADVICE_ADD_IGNORED_FILE, @@ -50,6 +50,7 @@ struct string_list; ADVICE_WAITING_FOR_EDITOR, ADVICE_SKIPPED_CHERRY_PICKS, ADVICE_WORKTREE_ADD_ORPHAN, + ADVICE_ADVICE_OFF, }; int git_default_advice_config(const char *var, const char *value); diff --git a/t/t0018-advice.sh b/t/t0018-advice.sh index c13057a4ca..0b6a8b4a10 100755 --- a/t/t0018-advice.sh +++ b/t/t0018-advice.sh @@ -30,4 +30,12 @@ test_expect_success 'advice should not be printed when config variable is set to test_must_be_empty actual ' +test_expect_success 'advice without the instructions to disable it' ' + cat >expect <<-\EOF && + hint: This is a piece of advice + EOF + test-tool -c advice.adviceOff=0 advise "This is a piece of advice" 2>actual && + test_cmp expect actual +' + test_done