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

[PATCH 2/3] commit: use `advise_if_enabled()` in `read_graft_file()`

From
Rubén Justo <rjusto@gmail.com>
Date
Dec 8, 2024, 08:12 UTC
Message-ID
<ec2a47c1-9bfd-4c80-a495-22154e6c0d24@gmail.com>
In-Reply-To
<0e139151-7162-42b3-afae-248c28bf4c4b@gmail.com>

We have a deprecation notice in `read_graft_file()` since f9f99b3f7d (Deprecate support for .git/info/grafts, 2018-04-29).

This deprecation notice is shown using `advice_enabled()` plus `advise()`.

Let's use the `advise_if_enabled()` API which combines the functionality of both APIs and offers some advantages, such as: standardizing the presentation of the help on how to disable the advice.

The test we have in t6001 "show advice that grafts are deprecated" does not need to be adjusted due to the changes in this step.

Signed-off-by: Rubén Justo <rjusto@gmail.com>
---
 commit.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/commit.c b/commit.c
index cc03a93036..8d92bc1044 100644
--- a/commit.c
+++ b/commit.c
@@ -267,16 +267,13 @@ static int read_graft_file(struct repository *r, const char *graft_file)
 	struct strbuf buf = STRBUF_INIT;
 	if (!fp)
 		return -1;
-	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"
-			 "Please use \"git replace --convert-graft-file\"\n"
-			 "to convert the grafts into replace refs.\n"
-			 "\n"
-			 "Turn this message off by running\n"
-			 "\"git config advice.graftFileDeprecated false\""));
+	if (!no_graft_file_deprecated_advice)
+		advise_if_enabled(ADVICE_GRAFT_FILE_DEPRECATED,
+			_("Support for <GIT_DIR>/info/grafts is deprecated\n"
+			  "and will be removed in a future Git version.\n"
+			  "\n"
+			  "Please use \"git replace --convert-graft-file\"\n"
+			  "to convert the grafts into replace refs.\n"));
 	while (!strbuf_getwholeline(&buf, fp, '\n')) {
 		/* The format is just "Commit Parent1 Parent2 ...\n" */
 		struct commit_graft *graft = read_graft_line(&buf);
-- 
2.47.1.407.gf6b6eee3e5
Previous: Rubén JustoNext: Rubén Justo
Message 9 of 16 in “advice: suggest using subcommand "git config set"”
  1. advice: suggest using subcommand "git config set"Bence Ferdinandy, Dec 4, 2024
  2. Justin ToblerDec 4, 2024
  3. Bence FerdinandyDec 5, 2024
  4. Patrick SteinhardtDec 5, 2024
  5. advice: suggest using subcommand "git config set"Bence Ferdinandy, Dec 5, 2024
  6. Patrick SteinhardtDec 6, 2024
  7. Rubén JustoDec 8, 2024
  8. 1/3 advice: enhance `detach_advice()` to `detach_advice_if_enabled()`Rubén Justo, Dec 8, 2024
  9. 2/3 commit: use `advise_if_enabled()` in `read_graft_file()`Rubén Justo, Dec 8, 2024
  10. 3/3 object-name: advice to avoid refs that resemble hashesRubén Justo, Dec 8, 2024
  11. Bence FerdinandyDec 9, 2024
  12. Bence FerdinandyDec 9, 2024
  13. Rubén JustoDec 9, 2024
  14. Bence FerdinandyDec 11, 2024
  15. Rubén JustoDec 11, 2024
  16. Junio C HamanoDec 6, 2024

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.