@@ -58,6 +58,9 @@ int read_fsmonitor_extension(struct index_state *istate, const void *data,
uint64_t timestamp;
struct strbuf last_update = STRBUF_INIT;
+ if (istate->sparse_index)
+ return 0;
+
if (sz < sizeof(uint32_t) + 1 + sizeof(uint32_t))
return error("corrupt fsmonitor extension (too short)");
@@ -98,7 +101,8 @@ void fill_fsmonitor_bitmap(struct index_state *istate)
{
unsigned int i, skipped = 0;
- ensure_full_index(istate);
+ if (istate->sparse_index)
+ return;
istate->fsmonitor_dirty = ewah_new();
for (i = 0; i < istate->cache_nr; i++) {
@@ -161,11 +165,7 @@ static int query_fsmonitor(int version, const char *last_update, struct strbuf *
static void fsmonitor_refresh_callback(struct index_state *istate, const char *name)
{
- int pos;
-
- ensure_full_index(istate);
-
- pos = index_name_pos(istate, name, strlen(name));
+ int pos = index_name_pos(istate, name, strlen(name));
if (pos >= 0) {
struct cache_entry *ce = istate->cache[pos];
@@ -190,7 +190,8 @@ void refresh_fsmonitor(struct index_state *istate)
char *buf;
unsigned int i;
- if (!core_fsmonitor || istate->fsmonitor_has_run_once)
+ if (!core_fsmonitor || istate->fsmonitor_has_run_once ||
+ istate->sparse_index)
return;
hook_version = fsmonitor_hook_version();
@@ -300,6 +301,9 @@ void add_fsmonitor(struct index_state *istate)
unsigned int i;
struct strbuf last_update = STRBUF_INIT;
+ if (istate->sparse_index)
+ return;
+
if (!istate->fsmonitor_last_update) {
trace_printf_key(&trace_fsmonitor, "add fsmonitor");
istate->cache_changed |= FSMONITOR_CHANGED;
@@ -335,6 +339,9 @@ void tweak_fsmonitor(struct index_state *istate)
unsigned int i;
int fsmonitor_enabled = git_config_get_fsmonitor();
+ if (istate->sparse_index)
+ fsmonitor_enabled = 0;
+
if (istate->fsmonitor_dirty) {
if (fsmonitor_enabled) {
ensure_full_index(istate);
@@ -3017,7 +3017,8 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
if (err)
return -1;
}
- if (!strip_extensions && istate->fsmonitor_last_update) {
+ if (!strip_extensions && istate->fsmonitor_last_update &&
+ !istate->sparse_index) {
struct strbuf sb = STRBUF_INIT;
write_fsmonitor_extension(&sb, istate);
@@ -388,7 +388,7 @@ test_expect_success 'sparse-index is expanded and converted back' '
init_repos &&
GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
- git -C sparse-index -c core.fsmonitor="" reset --hard &&
+ git -C sparse-index reset --hard &&
test_region index convert_to_sparse trace2.txt &&
test_region index ensure_full_index trace2.txt
'
@@ -398,19 +398,19 @@ test_expect_success 'sparse-index is not expanded' '
rm -f trace2.txt &&
GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
- git -C sparse-index -c core.fsmonitor="" status -uno &&
+ git -C sparse-index status -uno &&
test_region ! index ensure_full_index trace2.txt &&
rm trace2.txt &&
echo >>sparse-index/README.md &&
GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
- git -C sparse-index -c core.fsmonitor="" add -A &&
+ git -C sparse-index add -A &&
test_region ! index ensure_full_index trace2.txt &&
rm trace2.txt &&
echo >>sparse-index/extra.txt &&
GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
- git -C sparse-index -c core.fsmonitor="" add extra.txt &&
+ git -C sparse-index add extra.txt &&
test_region ! index ensure_full_index trace2.txt
'