]> git.ipfire.org Git - thirdparty/git.git/blobdiff - advice.c
treewide: remove unnecessary includes of cache.h
[thirdparty/git.git] / advice.c
index 6fda9edbc2474fe15c128014b99660034d269177..d6232439c3863b4c6136adfd12465b0aa714e81f 100644 (file)
--- a/advice.c
+++ b/advice.c
@@ -1,6 +1,8 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "advice.h"
 #include "config.h"
 #include "color.h"
+#include "gettext.h"
 #include "help.h"
 #include "string-list.h"
 
@@ -44,6 +46,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 +220,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."));
 }
 
@@ -261,3 +272,22 @@ void detach_advice(const char *new_name)
 
        fprintf(stderr, fmt, new_name);
 }
+
+void advise_on_moving_dirty_path(struct string_list *pathspec_list)
+{
+       struct string_list_item *item;
+
+       if (!pathspec_list->nr)
+               return;
+
+       fprintf(stderr, _("The following paths have been moved outside the\n"
+                         "sparse-checkout definition but are not sparse due to local\n"
+                         "modifications.\n"));
+       for_each_string_list_item(item, pathspec_list)
+               fprintf(stderr, "%s\n", item->string);
+
+       advise_if_enabled(ADVICE_UPDATE_SPARSE_PATH,
+                         _("To correct the sparsity of these paths, do the following:\n"
+                           "* Use \"git add --sparse <paths>\" to update the index\n"
+                           "* Use \"git sparse-checkout reapply\" to apply the sparsity rules"));
+}