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

[PATCH 3/5] advice.[ch]: remove advice.pushNonFastForward alias

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Oct 4, 2021, 01:58 UTC
Message-ID
<patch-3.5-00eaaeccbcb-20211004T015432Z-avarab@gmail.com>
In-Reply-To
<cover-0.5-00000000000-20211004T015432Z-avarab@gmail.com>

The advice.pushNonFastForward variable has been primarily known as advice.pushUpdateRejected since 1184564eac8 (push: rename config variable for more general use, 2012-12-02). It's been long enough by far that we can declare this deprecation period over and remove it.

The only downside for users is going to be that they'll potentially see a more verbose warning that they'll have to re-squash by changing their config, but that's hardly an undue burden.

Doing this allows us to simplify the advice_enabled() function down to something truly trivial.

Change the only in-tree user of this, it was added in fd47d7b94db (git-remote-mediawiki: obey advice.pushNonFastForward, 2011-09-27), and not renamed in 1184564eac8 along with the rest.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 advice.c                                    | 12 +-----------
 advice.h                                    |  1 -
 contrib/mw-to-git/git-remote-mediawiki.perl |  2 +-
 3 files changed, 2 insertions(+), 13 deletions(-)
diff --git a/advice.c b/advice.c
index 9691c7e7899..b395bc7d187 100644
--- a/advice.c
+++ b/advice.c
@@ -52,10 +52,6 @@ static struct {
 	[ADVICE_PUSH_FETCH_FIRST]			= { "pushFetchFirst", 1 },
 	[ADVICE_PUSH_NEEDS_FORCE]			= { "pushNeedsForce", 1 },
 	[ADVICE_PUSH_REF_NEEDS_UPDATE]			= { "pushRefNeedsUpdate", 1 },
-
-	/* make this an alias for backward compatibility */
-	[ADVICE_PUSH_UPDATE_REJECTED_ALIAS]		= { "pushNonFastForward", 1 },
-
 	[ADVICE_PUSH_NON_FF_CURRENT]			= { "pushNonFFCurrent", 1 },
 	[ADVICE_PUSH_NON_FF_MATCHING]			= { "pushNonFFMatching", 1 },
 	[ADVICE_PUSH_UNQUALIFIED_REF_NAME]		= { "pushUnqualifiedRefName", 1 },
@@ -116,13 +112,7 @@ void advise(const char *advice, ...)
 
 int advice_enabled(enum advice_type type)
 {
-	switch(type) {
-	case ADVICE_PUSH_UPDATE_REJECTED:
-		return advice_setting[ADVICE_PUSH_UPDATE_REJECTED].enabled &&
-		       advice_setting[ADVICE_PUSH_UPDATE_REJECTED_ALIAS].enabled;
-	default:
-		return advice_setting[type].enabled;
-	}
+	return advice_setting[type].enabled;
 }
 
 void advise_if_enabled(enum advice_type type, const char *advice, ...)
diff --git a/advice.h b/advice.h
index 694219f5cb2..ab25c6ba9a0 100644
--- a/advice.h
+++ b/advice.h
@@ -32,7 +32,6 @@ enum advice_type {
 	ADVICE_PUSH_NON_FF_CURRENT,
 	ADVICE_PUSH_NON_FF_MATCHING,
 	ADVICE_PUSH_UNQUALIFIED_REF_NAME,
-	ADVICE_PUSH_UPDATE_REJECTED_ALIAS,
 	ADVICE_PUSH_UPDATE_REJECTED,
 	ADVICE_PUSH_REF_NEEDS_UPDATE,
 	ADVICE_RESET_QUIET_WARNING,
diff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl
index a5624413dc1..158e89e5048 100755
--- a/contrib/mw-to-git/git-remote-mediawiki.perl
+++ b/contrib/mw-to-git/git-remote-mediawiki.perl
@@ -983,7 +983,7 @@ sub mw_import_revids {
 }
 
 sub error_non_fast_forward {
-	my $advice = run_git_quoted(["config", "--bool", "advice.pushNonFastForward"]);
+	my $advice = run_git_quoted(["config", "--bool", "advice.pushUpdateRejected"]);
 	chomp($advice);
 	if ($advice ne 'false') {
 		# Native git-push would show this after the summary.
-- 
2.33.0.1404.g7bcfc82b295
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 4 of 6 in “advice API: simplification, small fixes, readability”
  1. 0/5 advice API: simplification, small fixes, readabilityÆvar Arnfjörð Bjarmason, Oct 4, 2021
  2. 2/5 advice output: emit empty lines as "hint:", not "hint: "Ævar Arnfjörð Bjarmason, Oct 4, 2021
  3. 1/5 advice.h: don't indent top-level enumÆvar Arnfjörð Bjarmason, Oct 4, 2021
  4. 3/5 advice.[ch]: remove advice.pushNonFastForward aliasÆvar Arnfjörð Bjarmason, Oct 4, 2021
  5. 4/5 advice API: revamp the API, againÆvar Arnfjörð Bjarmason, Oct 4, 2021
  6. 5/5 advice.[ch]: sort enum fields in alphabetical orderÆvar Arnfjörð Bjarmason, Oct 4, 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.