It is not unusual for multiple distinct versions of Git to act on a
single repository.  For example, some IDEs bundle a particular version
of Git, which can be a different version from the system copy of Git,
or on a Mac, /usr/bin/git quickly goes out of sync with the Homebrew
git in /usr/local/bin/git.

When a newer version of Git writes an index file that an older version
of Git does not know how to make full use of, this is a teaching
opportunity.  The user may not be aware of what version of Git they
are using.  Print an advice message to help the user to use the most
full featured version of Git (e.g. by futzing with their PATH).

  warning: ignoring optional IEOT index extension
  hint: This is likely due to the file having been written by a newer
  hint: version of Git than is reading it.  You can upgrade Git to
  hint: take advantage of performance improvements from the updated
  hint: file format.
  hint:
  hint: You can run "git config advice.unknownIndexExtension false"
  hint: to suppress this message.

This replaces the message

  ignoring IEOT extension

that existed previously and did not provide enough detail for a user
to act on it or suppress it.

Helped-by: Junio C Hamano <gits...@pobox.com>
Signed-off-by: Jonathan Nieder <jrnie...@gmail.com>
---
New, based on Junio's hints about the message removed in patch 3/5.

That's the end of the series.  Thanks for reading, and thanks again
for your help so far.

 advice.c     |  2 ++
 advice.h     |  1 +
 read-cache.c | 11 +++++++++++
 3 files changed, 14 insertions(+)

diff --git a/advice.c b/advice.c
index 5f35656409..91a55046fd 100644
--- a/advice.c
+++ b/advice.c
@@ -24,6 +24,7 @@ int advice_add_embedded_repo = 1;
 int advice_ignored_hook = 1;
 int advice_waiting_for_editor = 1;
 int advice_graft_file_deprecated = 1;
+int advice_unknown_index_extension = 1;
 int advice_checkout_ambiguous_remote_branch_name = 1;
 
 static int advice_use_color = -1;
@@ -78,6 +79,7 @@ static struct {
        { "ignoredHook", &advice_ignored_hook },
        { "waitingForEditor", &advice_waiting_for_editor },
        { "graftFileDeprecated", &advice_graft_file_deprecated },
+       { "unknownIndexExtension", &advice_unknown_index_extension },
        { "checkoutAmbiguousRemoteBranchName", 
&advice_checkout_ambiguous_remote_branch_name },
 
        /* make this an alias for backward compatibility */
diff --git a/advice.h b/advice.h
index 696bf0e7d2..8da0845cfc 100644
--- a/advice.h
+++ b/advice.h
@@ -24,6 +24,7 @@ extern int advice_add_embedded_repo;
 extern int advice_ignored_hook;
 extern int advice_waiting_for_editor;
 extern int advice_graft_file_deprecated;
+extern int advice_unknown_index_extension;
 extern int advice_checkout_ambiguous_remote_branch_name;
 
 int git_default_advice_config(const char *var, const char *value);
diff --git a/read-cache.c b/read-cache.c
index 002ed2c1e4..d1d903e5a1 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1727,6 +1727,17 @@ static int read_index_extension(struct index_state 
*istate,
                        return error("index uses %.4s extension, which we do 
not understand",
                                     ext);
                trace_printf("ignoring %.4s extension\n", ext);
+               if (advice_unknown_index_extension) {
+                       warning(_("ignoring optional %.4s index extension"), 
ext);
+                       advise(_("This is likely due to the file having been 
written by a newer\n"
+                                "version of Git than is reading it. You can 
upgrade Git to\n"
+                                "take advantage of performance improvements 
from the updated\n"
+                                "file format.\n"
+                                "\n"
+                                "Run \"%s\"\n"
+                                "to suppress this message."),
+                              "git config advice.unknownIndexExtension false");
+               }
                break;
        }
        return 0;
-- 
2.20.0.rc0.387.gc7a69e6b6c

Reply via email to