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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 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




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux