summaryrefslogtreecommitdiff
path: root/sparse-index.c
diff options
context:
space:
mode:
authorLibravatar Jiang Xin <worldhello.net@gmail.com>2021-08-03 17:03:35 +0800
committerLibravatar Jiang Xin <worldhello.net@gmail.com>2021-08-03 17:03:35 +0800
commit972c9cf6aed660f3b4189a8f2adda505e67110ff (patch)
tree350bb2a29eb3360cdf36a30d8c8e7c76c3e61851 /sparse-index.c
parentl10n: fixed typos of mismatched constant strings (diff)
parentGit 2.33-rc0 (diff)
downloadtgif-972c9cf6aed660f3b4189a8f2adda505e67110ff.tar.xz
Merge branch 'master' of github.com:git/git
* 'master' of github.com:git/git: (397 commits) Git 2.33-rc0 The seventh batch ci/install-dependencies: handle "sparse" job package installs ci: run "apt-get update" before "apt-get install" cache-tree: prefetch in partial clone read-tree unpack-trees: refactor prefetching code pack-bitmap: check pack validity when opening bitmap bundle tests: use test_cmp instead of grep bundle tests: use ">file" not ": >file" The sixth batch doc: pull: fix rebase=false documentation pack-bitmap: clarify comment in filter_bitmap_exclude_type() doc: clarify description of 'submodule.recurse' doc/git-config: simplify "override" advice for FILES section doc/git-config: clarify GIT_CONFIG environment variable doc/git-config: explain --file instead of referring to GIT_CONFIG t0000: fix test if run with TEST_OUTPUT_DIRECTORY multi-pack-index: fix potential segfault without sub-command refs/debug: quote prefix t0000: clear GIT_SKIP_TESTS before running sub-tests ...
Diffstat (limited to 'sparse-index.c')
-rw-r--r--sparse-index.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/sparse-index.c b/sparse-index.c
index b0d5dc5f08..53c8f711cc 100644
--- a/sparse-index.c
+++ b/sparse-index.c
@@ -34,7 +34,7 @@ static int convert_to_sparse_rec(struct index_state *istate,
int i, can_convert = 1;
int start_converted = num_converted;
enum pattern_match_result match;
- int dtype;
+ int dtype = DT_UNKNOWN;
struct strbuf child_path = STRBUF_INIT;
struct pattern_list *pl = istate->sparse_checkout_patterns;
@@ -116,6 +116,17 @@ int set_sparse_index_config(struct repository *repo, int enable)
return res;
}
+static int index_has_unmerged_entries(struct index_state *istate)
+{
+ int i;
+ for (i = 0; i < istate->cache_nr; i++) {
+ if (ce_stage(istate->cache[i]))
+ return 1;
+ }
+
+ return 0;
+}
+
int convert_to_sparse(struct index_state *istate)
{
int test_env;
@@ -152,6 +163,13 @@ int convert_to_sparse(struct index_state *istate)
return -1;
}
+ /*
+ * NEEDSWORK: If we have unmerged entries, then stay full.
+ * Unmerged entries prevent the cache-tree extension from working.
+ */
+ if (index_has_unmerged_entries(istate))
+ return 0;
+
if (cache_tree_update(istate, 0)) {
warning(_("unable to update cache-tree, staying full"));
return -1;
@@ -168,6 +186,10 @@ int convert_to_sparse(struct index_state *istate)
cache_tree_free(&istate->cache_tree);
cache_tree_update(istate, 0);
+ istate->fsmonitor_has_run_once = 0;
+ FREE_AND_NULL(istate->fsmonitor_dirty);
+ FREE_AND_NULL(istate->fsmonitor_last_update);
+
istate->sparse_index = 1;
trace2_region_leave("index", "convert_to_sparse", istate->repo);
return 0;
@@ -195,7 +217,7 @@ static int add_path_to_index(const struct object_id *oid,
strbuf_addstr(base, path);
ce = make_cache_entry(istate, mode, oid, base->buf, 0, 0);
- ce->ce_flags |= CE_SKIP_WORKTREE;
+ ce->ce_flags |= CE_SKIP_WORKTREE | CE_EXTENDED;
set_index_entry(istate, istate->cache_nr++, ce);
strbuf_setlen(base, len);
@@ -264,6 +286,9 @@ void ensure_full_index(struct index_state *istate)
istate->cache = full->cache;
istate->cache_nr = full->cache_nr;
istate->cache_alloc = full->cache_alloc;
+ istate->fsmonitor_has_run_once = 0;
+ FREE_AND_NULL(istate->fsmonitor_dirty);
+ FREE_AND_NULL(istate->fsmonitor_last_update);
strbuf_release(&base);
free(full);