git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/4] fsmonitor: avoid overriding `cache_changed` bits

From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Date
Mar 22, 2023, 16:00 UTC
Message-ID
<c1c35f0f026993c493eaae3cf643b25c339205c4.1679500859.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.1497.git.1679500859.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>

As of e636a7b4d030 (read-cache: be specific what part of the index has changed, 2014-06-13), the paradigm `cache_changed = 1` fell out of fashion and it became a bit field instead.

This is important because some bits have specific meaning and should not be unset without care, e.g. `SPLIT_INDEX_ORDERED`.

However, b5a816975206 (mark_fsmonitor_valid(): mark the index as changed if needed, 2019-05-24) did use the `cache_changed` attribute as if it were a Boolean instead of a bit field.

That not only would override the `SPLIT_INDEX_ORDERED` bit when marking index entries as valid via the FSMonitor, but worse: it would set the `SOMETHING_OTHER` bit (whose value is 1). This means that Git would unnecessarily force a full index to be written out when a split index was asked for.

Let's instead use the bit that is specifically intended to indicate FSMonitor-triggered changes, allowing the split-index feature to work as designed.

Noticed-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 fsmonitor.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fsmonitor.h b/fsmonitor.h
index edf7ce5203b..778707b131b 100644
--- a/fsmonitor.h
+++ b/fsmonitor.h
@@ -86,7 +86,7 @@ static inline void mark_fsmonitor_valid(struct index_state *istate, struct cache
 	    !(ce->ce_flags & CE_FSMONITOR_VALID)) {
 		if (S_ISGITLINK(ce->ce_mode))
 			return;
-		istate->cache_changed = 1;
+		istate->cache_changed |= FSMONITOR_CHANGED;
 		ce->ce_flags |= CE_FSMONITOR_VALID;
 		trace_printf_key(&trace_fsmonitor, "mark_fsmonitor_clean '%s'", ce->name);
 	}
-- 
gitgitgadget
Previous: Jeff HostetlerNext: Johannes Schindelin via GitGitGadget
Message 9 of 19 in “Fix a few split-index bugs”
  1. 0/4 Fix a few split-index bugsJohannes Schindelin via GitGitGadget, Mar 22, 2023
  2. 1/4 split-index & fsmonitor: demonstrate a bugJohannes Schindelin via GitGitGadget, Mar 22, 2023
  3. Jeff HostetlerMar 23, 2023
  4. 2/4 split-index; stop abusing the `base_oid` to strip the "link" extensionJohannes Schindelin via GitGitGadget, Mar 22, 2023
  5. Junio C HamanoMar 22, 2023
  6. Jeff HostetlerMar 23, 2023
  7. Junio C HamanoMar 23, 2023
  8. Jeff HostetlerMar 23, 2023
  9. 3/4 fsmonitor: avoid overriding `cache_changed` bitsJohannes Schindelin via GitGitGadget, Mar 22, 2023
  10. 4/4 unpack-trees: take care to propagate the split-index flagJohannes Schindelin via GitGitGadget, Mar 22, 2023
  11. Jeff HostetlerMar 23, 2023
  12. Junio C HamanoMar 22, 2023
  13. 0/4 Fix a few split-index bugsJohannes Schindelin via GitGitGadget, Mar 26, 2023
  14. 3/4 fsmonitor: avoid overriding `cache_changed` bitsJohannes Schindelin via GitGitGadget, Mar 26, 2023
  15. 2/4 split-index; stop abusing the `base_oid` to strip the "link" extensionJohannes Schindelin via GitGitGadget, Mar 26, 2023
  16. 1/4 split-index & fsmonitor: demonstrate a bugJohannes Schindelin via GitGitGadget, Mar 26, 2023
  17. 4/4 unpack-trees: take care to propagate the split-index flagJohannes Schindelin via GitGitGadget, Mar 26, 2023
  18. Jeff HostetlerMar 27, 2023
  19. Junio C HamanoMar 27, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.