update-index: warn in case of split-index incoherency
authorChristian Couder <christian.couder@gmail.com>
Mon, 27 Feb 2017 18:00:03 +0000 (19:00 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 1 Mar 2017 21:24:21 +0000 (13:24 -0800)
When users are using `git update-index --(no-)split-index`, they
may expect the split-index feature to be used or not according to
the option they just used, but this might not be the case if the
new "core.splitIndex" config variable has been set. In this case
let's warn about what will happen and why.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/update-index.c
index 24fdadfa4b949108677268b9912f3970960138cc..d74d72cc7fad93980abd409d2c9dc10ae4652fd3 100644 (file)
@@ -1099,12 +1099,21 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
        }
 
        if (split_index > 0) {
+               if (git_config_get_split_index() == 0)
+                       warning(_("core.splitIndex is set to false; "
+                                 "remove or change it, if you really want to "
+                                 "enable split index"));
                if (the_index.split_index)
                        the_index.cache_changed |= SPLIT_INDEX_ORDERED;
                else
                        add_split_index(&the_index);
-       } else if (!split_index)
+       } else if (!split_index) {
+               if (git_config_get_split_index() == 1)
+                       warning(_("core.splitIndex is set to true; "
+                                 "remove or change it, if you really want to "
+                                 "disable split index"));
                remove_split_index(&the_index);
+       }
 
        switch (untracked_cache) {
        case UC_UNSPECIFIED: