git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[RFC PATCH v3 4/4] advice: move advice.graftFileDeprecated squashing to commit.[ch]

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Aug 6, 2021, 19:13 UTC
Message-ID
<RFC-patch-v3-4.4-fe6f6328f9-20210806T191231Z-avarab@gmail.com>
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
Previous: Eric SunshineNext: Ævar Arnfjörð Bjarmason
Message 26 of 32 in “advice: remove usage of `advice_*` global variables”
  1. 0/4 advice: remove usage of `advice_*` global variablesBen Boeckel, Jul 31, 2021
  2. 1/4 advice: add a function to set the value of an advice typeBen Boeckel, Jul 31, 2021
  3. Johannes SchindelinAug 2, 2021
  4. 2/4 advice: add enum variants for missing advice variablesBen Boeckel, Jul 31, 2021
  5. Johannes SchindelinAug 2, 2021
  6. Ben BoeckelAug 3, 2021
  7. 3/4 advice: remove uses of global `advice_` variablesBen Boeckel, Jul 31, 2021
  8. Johannes SchindelinAug 2, 2021
  9. Ben BoeckelAug 3, 2021
  10. 4/4 advice: remove static global variables for advice trackingBen Boeckel, Jul 31, 2021
  11. Johannes SchindelinAug 2, 2021
  12. Ben BoeckelAug 3, 2021
  13. Johannes SchindelinAug 2, 2021
  14. Ben BoeckelAug 3, 2021
  15. 0/4 advice: remove usage of `advice_*` global variablesBen Boeckel, Aug 5, 2021
  16. 1/4 advice: add enum variants for missing advice variablesBen Boeckel, Aug 5, 2021
  17. 2/4 advice: remove read uses of global `advice_` variablesBen Boeckel, Aug 5, 2021
  18. 3/4 advice: add `advice_set` to update advice settings at runtimeBen Boeckel, Aug 5, 2021
  19. 4/4 advice: remove static global variables for advice trackingBen Boeckel, Aug 5, 2021
  20. 0/4 advice: remove usage of `advice_*` global variablesÆvar Arnfjörð Bjarmason, Aug 6, 2021
  21. 2/4 advice: remove read uses of most global `advice_` variablesÆvar Arnfjörð Bjarmason, Aug 6, 2021
  22. Eric SunshineAug 6, 2021
  23. 1/4 advice: add enum variants for missing advice variablesÆvar Arnfjörð Bjarmason, Aug 6, 2021
  24. 3/4 advice: remove use of global advice_add_embedded_repoÆvar Arnfjörð Bjarmason, Aug 6, 2021
  25. Eric SunshineAug 6, 2021
  26. 4/4 advice: move advice.graftFileDeprecated squashing to commit.[ch]Ævar Arnfjörð Bjarmason, Aug 6, 2021
  27. 0/4 advice: remove usage of `advice_*` global variablesÆvar Arnfjörð Bjarmason, Aug 23, 2021
  28. 1/4 advice: add enum variants for missing advice variablesÆvar Arnfjörð Bjarmason, Aug 23, 2021
  29. 2/4 advice: remove read uses of most global `advice_` variablesÆvar Arnfjörð Bjarmason, Aug 23, 2021
  30. 3/4 advice: remove use of global advice_add_embedded_repoÆvar Arnfjörð Bjarmason, Aug 23, 2021
  31. 4/4 advice: move advice.graftFileDeprecated squashing to commit.[ch]Ævar Arnfjörð Bjarmason, Aug 23, 2021
  32. Junio C HamanoAug 25, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.