From cef4fc7ebe869e910d0fd5643cd60328ed76356a Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Mon, 27 Feb 2017 19:00:01 +0100 Subject: split-index: add {add,remove}_split_index() functions Also use the functions in cmd_update_index() in builtin/update-index.c. These functions will be used in a following commit to tweak our use of the split-index feature depending on the setting of a configuration variable. Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano --- builtin/update-index.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'builtin/update-index.c') diff --git a/builtin/update-index.c b/builtin/update-index.c index d530e89368..24fdadfa4b 100644 --- a/builtin/update-index.c +++ b/builtin/update-index.c @@ -1099,18 +1099,12 @@ int cmd_update_index(int argc, const char **argv, const char *prefix) } if (split_index > 0) { - init_split_index(&the_index); - the_index.cache_changed |= SPLIT_INDEX_ORDERED; - } else if (!split_index && the_index.split_index) { - /* - * can't discard_split_index(&the_index); because that - * will destroy split_index->base->cache[], which may - * be shared with the_index.cache[]. So yeah we're - * leaking a bit here. - */ - the_index.split_index = NULL; - the_index.cache_changed |= SOMETHING_CHANGED; - } + if (the_index.split_index) + the_index.cache_changed |= SPLIT_INDEX_ORDERED; + else + add_split_index(&the_index); + } else if (!split_index) + remove_split_index(&the_index); switch (untracked_cache) { case UC_UNSPECIFIED: -- cgit v1.2.3 From 6cc1053375d8e138b8f05dde4cd0d4ab8f92254a Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Mon, 27 Feb 2017 19:00:03 +0100 Subject: update-index: warn in case of split-index incoherency 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 Signed-off-by: Junio C Hamano --- builtin/update-index.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'builtin/update-index.c') diff --git a/builtin/update-index.c b/builtin/update-index.c index 24fdadfa4b..d74d72cc7f 100644 --- a/builtin/update-index.c +++ b/builtin/update-index.c @@ -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: -- cgit v1.2.3