Skip to content

Commit ee70c12

Browse files
jrngitster
authored andcommitted
index: offer advice for unknown index extensions
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 <[email protected]> Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 359e6b6 commit ee70c12

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

advice.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ int advice_add_embedded_repo = 1;
2424
int advice_ignored_hook = 1;
2525
int advice_waiting_for_editor = 1;
2626
int advice_graft_file_deprecated = 1;
27+
int advice_unknown_index_extension = 1;
2728
int advice_checkout_ambiguous_remote_branch_name = 1;
2829

2930
static int advice_use_color = -1;
@@ -78,6 +79,7 @@ static struct {
7879
{ "ignoredHook", &advice_ignored_hook },
7980
{ "waitingForEditor", &advice_waiting_for_editor },
8081
{ "graftFileDeprecated", &advice_graft_file_deprecated },
82+
{ "unknownIndexExtension", &advice_unknown_index_extension },
8183
{ "checkoutAmbiguousRemoteBranchName", &advice_checkout_ambiguous_remote_branch_name },
8284

8385
/* make this an alias for backward compatibility */

advice.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ extern int advice_add_embedded_repo;
2424
extern int advice_ignored_hook;
2525
extern int advice_waiting_for_editor;
2626
extern int advice_graft_file_deprecated;
27+
extern int advice_unknown_index_extension;
2728
extern int advice_checkout_ambiguous_remote_branch_name;
2829

2930
int git_default_advice_config(const char *var, const char *value);

read-cache.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,6 +1727,17 @@ static int read_index_extension(struct index_state *istate,
17271727
return error("index uses %.4s extension, which we do not understand",
17281728
ext);
17291729
trace_printf("ignoring %.4s extension\n", ext);
1730+
if (advice_unknown_index_extension) {
1731+
warning(_("ignoring optional %.4s index extension"), ext);
1732+
advise(_("This is likely due to the file having been written by a newer\n"
1733+
"version of Git than is reading it. You can upgrade Git to\n"
1734+
"take advantage of performance improvements from the updated\n"
1735+
"file format.\n"
1736+
"\n"
1737+
"Run \"%s\"\n"
1738+
"to suppress this message."),
1739+
"git config advice.unknownIndexExtension false");
1740+
}
17301741
break;
17311742
}
17321743
return 0;

0 commit comments

Comments
 (0)