From cf26b40b5149f8bf4ee7847a0f975f1e255935a5 Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Mon, 21 Jun 2021 13:09:06 -0400 Subject: [PATCH] sparse-index: silently return when not using cone-mode patterns This commit is necessary becaue of the previous change that turned on the sparse-index by default. Some cases in t1091 now enable the sparse index and hit different corner cases around cone mode patterns. Signed-off-by: Derrick Stolee --- sparse-index.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/sparse-index.c b/sparse-index.c index 489306029dc36d..6d0c3e7c9684d0 100644 --- a/sparse-index.c +++ b/sparse-index.c @@ -130,6 +130,7 @@ static int index_has_unmerged_entries(struct index_state *istate) int convert_to_sparse(struct index_state *istate) { int test_env; + if (istate->split_index || istate->sparse_index || !core_apply_sparse_checkout || !core_sparse_checkout_cone) return 0; @@ -158,10 +159,16 @@ int convert_to_sparse(struct index_state *istate) return 0; } - if (!istate->sparse_checkout_patterns->use_cone_patterns) { - warning(_("attempting to use sparse-index without cone mode")); - return -1; - } + /* + * We need cone-mode patterns to use sparse-index. If a user edits + * their sparse-checkout file manually, then we can detect during + * parsing that they are not actually using cone-mode patterns and + * hence we need to abort this conversion _without error_. Warnings + * already exist in the pattern parsing to inform the user of their + * bad patterns. + */ + if (!istate->sparse_checkout_patterns->use_cone_patterns) + return 0; /* * NEEDSWORK: If we have unmerged entries, then stay full.