diff mbox series

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

Message ID ec2a47c1-9bfd-4c80-a495-22154e6c0d24@gmail.com (mailing list archive)
State New
Headers show
Series [1/3] advice: enhance `detach_advice()` to `detach_advice_if_enabled()` | expand

Commit Message

Rubén Justo Dec. 8, 2024, 8:12 a.m. UTC
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 mbox series

Patch

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);