All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: git@vger.kernel.org
Cc: "Ben Boeckel" <mathstuf@gmail.com>,
	"Junio C Hamano" <gitster@pobox.com>,
	"Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [RFC PATCH v3 4/4] advice: move advice.graftFileDeprecated squashing to commit.[ch]
Date: Fri,  6 Aug 2021 21:13:18 +0200	[thread overview]
Message-ID: <RFC-patch-v3-4.4-fe6f6328f9-20210806T191231Z-avarab@gmail.com> (raw)
In-Reply-To: <RFC-cover-v3-0.4-0000000000-20210806T191231Z-avarab@gmail.com>

Move the squashing of the advice.graftFileDeprecated advice over to an
external variable in commit.[ch], allowing advice() to purely use the
new-style API of invoking advice() with an enum.

See 8821e90a09a (advice: don't pointlessly suggest
--convert-graft-file, 2018-11-27) for why quieting this advice was
needed. It's more straightforward to move this code to commit.[ch] and
use it builtin/replace.c, than to go through the indirection of
advice.[ch].

Because this was the last advice_config variable we can remove that
old facility from advice.c.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 advice.c          | 16 ----------------
 advice.h          |  2 --
 builtin/replace.c |  2 +-
 commit.c          |  4 +++-
 commit.h          |  1 +
 5 files changed, 5 insertions(+), 20 deletions(-)

diff --git a/advice.c b/advice.c
index 41cfea82d0..e716ddebff 100644
--- a/advice.c
+++ b/advice.c
@@ -4,8 +4,6 @@
 #include "help.h"
 #include "string-list.h"
 
-int advice_graft_file_deprecated = 1;
-
 static int advice_use_color = -1;
 static char advice_colors[][COLOR_MAXLEN] = {
 	GIT_COLOR_RESET,
@@ -33,13 +31,6 @@ static const char *advise_get_color(enum color_advice ix)
 	return "";
 }
 
-static struct {
-	const char *name;
-	int *preference;
-} advice_config[] = {
-	{ "graftFileDeprecated", &advice_graft_file_deprecated },
-};
-
 static struct {
 	const char *key;
 	int enabled;
@@ -162,13 +153,6 @@ int git_default_advice_config(const char *var, const char *value)
 	if (!skip_prefix(var, "advice.", &k))
 		return 0;
 
-	for (i = 0; i < ARRAY_SIZE(advice_config); i++) {
-		if (strcasecmp(k, advice_config[i].name))
-			continue;
-		*advice_config[i].preference = git_config_bool(var, value);
-		break;
-	}
-
 	for (i = 0; i < ARRAY_SIZE(advice_setting); i++) {
 		if (strcasecmp(k, advice_setting[i].key))
 			continue;
diff --git a/advice.h b/advice.h
index 4b754f4c62..e380a0562e 100644
--- a/advice.h
+++ b/advice.h
@@ -5,8 +5,6 @@
 
 struct string_list;
 
-extern int advice_graft_file_deprecated;
-
 /*
  * To add a new advice, you need to:
  * Define a new advice_type.
diff --git a/builtin/replace.c b/builtin/replace.c
index cd48765911..946938d011 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -507,7 +507,7 @@ static int convert_graft_file(int force)
 	if (!fp)
 		return -1;
 
-	advice_graft_file_deprecated = 0;
+	no_graft_file_deprecated_advice = 1;
 	while (strbuf_getline(&buf, fp) != EOF) {
 		if (*buf.buf == '#')
 			continue;
diff --git a/commit.c b/commit.c
index 143f472c0f..551de4903c 100644
--- a/commit.c
+++ b/commit.c
@@ -25,6 +25,7 @@
 static struct commit_extra_header *read_commit_extra_header_lines(const char *buf, size_t len, const char **);
 
 int save_commit_buffer = 1;
+int no_graft_file_deprecated_advice;
 
 const char *commit_type = "commit";
 
@@ -190,7 +191,8 @@ static int read_graft_file(struct repository *r, const char *graft_file)
 	struct strbuf buf = STRBUF_INIT;
 	if (!fp)
 		return -1;
-	if (advice_graft_file_deprecated)
+	if (!no_graft_file_deprecated_advice &&
+	    advice_enabled(ADVICE_GRAFT_FILE_DEPRECATED))
 		advise(_("Support for <GIT_DIR>/info/grafts is deprecated\n"
 			 "and will be removed in a future Git version.\n"
 			 "\n"
diff --git a/commit.h b/commit.h
index df42eb434f..3ea32766bc 100644
--- a/commit.h
+++ b/commit.h
@@ -41,6 +41,7 @@ struct commit {
 };
 
 extern int save_commit_buffer;
+extern int no_graft_file_deprecated_advice;
 extern const char *commit_type;
 
 /* While we can decorate any object with a name, it's only used for commits.. */
-- 
2.33.0.rc0.680.gf07173a897a


  parent reply	other threads:[~2021-08-06 19:13 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-31  2:25 [PATCH v1 0/4] advice: remove usage of `advice_*` global variables Ben Boeckel
2021-07-31  2:25 ` [PATCH v1 1/4] advice: add a function to set the value of an advice type Ben Boeckel
2021-08-02 21:56   ` Johannes Schindelin
2021-07-31  2:25 ` [PATCH v1 2/4] advice: add enum variants for missing advice variables Ben Boeckel
2021-08-02 21:52   ` Johannes Schindelin
2021-08-03  0:36     ` Ben Boeckel
2021-07-31  2:25 ` [PATCH v1 3/4] advice: remove uses of global `advice_` variables Ben Boeckel
2021-08-02 22:06   ` Johannes Schindelin
2021-08-03  0:42     ` Ben Boeckel
2021-07-31  2:25 ` [PATCH v1 4/4] advice: remove static global variables for advice tracking Ben Boeckel
2021-08-02 22:09   ` Johannes Schindelin
2021-08-03  0:44     ` Ben Boeckel
2021-08-02 22:15 ` [PATCH v1 0/4] advice: remove usage of `advice_*` global variables Johannes Schindelin
2021-08-03  0:45   ` Ben Boeckel
2021-08-05 23:03 ` [PATCH v2 " Ben Boeckel
2021-08-05 23:03   ` [PATCH v2 1/4] advice: add enum variants for missing advice variables Ben Boeckel
2021-08-05 23:03   ` [PATCH v2 2/4] advice: remove read uses of global `advice_` variables Ben Boeckel
2021-08-05 23:03   ` [PATCH v2 3/4] advice: add `advice_set` to update advice settings at runtime Ben Boeckel
2021-08-05 23:03   ` [PATCH v2 4/4] advice: remove static global variables for advice tracking Ben Boeckel
2021-08-06 19:13   ` [RFC PATCH v3 0/4] advice: remove usage of `advice_*` global variables Ævar Arnfjörð Bjarmason
2021-08-06 19:13     ` [RFC PATCH v3 1/4] advice: add enum variants for missing advice variables Ævar Arnfjörð Bjarmason
2021-08-06 19:13     ` [RFC PATCH v3 2/4] advice: remove read uses of most global `advice_` variables Ævar Arnfjörð Bjarmason
2021-08-06 19:30       ` Eric Sunshine
2021-08-06 19:13     ` [RFC PATCH v3 3/4] advice: remove use of global advice_add_embedded_repo Ævar Arnfjörð Bjarmason
2021-08-06 20:01       ` Eric Sunshine
2021-08-06 19:13     ` Ævar Arnfjörð Bjarmason [this message]
2021-08-23 10:43     ` [PATCH v4 0/4] advice: remove usage of `advice_*` global variables Ævar Arnfjörð Bjarmason
2021-08-23 10:43       ` [PATCH v4 1/4] advice: add enum variants for missing advice variables Ævar Arnfjörð Bjarmason
2021-08-23 10:44       ` [PATCH v4 2/4] advice: remove read uses of most global `advice_` variables Ævar Arnfjörð Bjarmason
2021-08-23 10:44       ` [PATCH v4 3/4] advice: remove use of global advice_add_embedded_repo Ævar Arnfjörð Bjarmason
2021-08-23 10:44       ` [PATCH v4 4/4] advice: move advice.graftFileDeprecated squashing to commit.[ch] Ævar Arnfjörð Bjarmason
2021-08-25 19:07         ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=RFC-patch-v3-4.4-fe6f6328f9-20210806T191231Z-avarab@gmail.com \
    --to=avarab@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=mathstuf@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.