From 765071a8f27fcaae27ce940b3a784b9d586faa12 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Tue, 7 Mar 2023 20:48:33 -0600 Subject: advice: add diverging advice for novices The user might not necessarily know why ff only was configured, maybe an admin did it, or the installer (Git for Windows), or perhaps they just followed some online advice. This can happen not only on pull.ff=only, but merge.ff=only too. Even worse if the user has configured pull.rebase=false and merge.ff=only, because in those cases a diverging merge will constantly keep failing. There's no trivial way to get out of this other than `git merge --no-ff`. Let's not assume our users are experts in git who completely understand all their configurations. Signed-off-by: Felipe Contreras Acked-by: Taylor Blau Signed-off-by: Junio C Hamano --- advice.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'advice.c') diff --git a/advice.c b/advice.c index fd18968943..fbc59f9c6d 100644 --- a/advice.c +++ b/advice.c @@ -44,6 +44,7 @@ static struct { [ADVICE_COMMIT_BEFORE_MERGE] = { "commitBeforeMerge", 1 }, [ADVICE_DETACHED_HEAD] = { "detachedHead", 1 }, [ADVICE_SUGGEST_DETACHING_HEAD] = { "suggestDetachingHead", 1 }, + [ADVICE_DIVERGING] = { "diverging", 1 }, [ADVICE_FETCH_SHOW_FORCED_UPDATES] = { "fetchShowForcedUpdates", 1 }, [ADVICE_GRAFT_FILE_DEPRECATED] = { "graftFileDeprecated", 1 }, [ADVICE_IGNORED_HOOK] = { "ignoredHook", 1 }, @@ -217,6 +218,14 @@ void NORETURN die_conclude_merge(void) void NORETURN die_ff_impossible(void) { + advise_if_enabled(ADVICE_DIVERGING, + _("Diverging branches can't be fast-forwarded, you need to either:\n" + "\n" + "\tgit merge --no-ff\n" + "\n" + "or:\n" + "\n" + "\tgit rebase\n")); die(_("Not possible to fast-forward, aborting.")); } -- cgit v1.2.3