]> git.ipfire.org Git - thirdparty/git.git/commit - fsmonitor.h
fsmonitor: avoid overriding `cache_changed` bits
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Sun, 26 Mar 2023 22:45:42 +0000 (22:45 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 Mar 2023 16:40:39 +0000 (09:40 -0700)
commitbe6b65b91bb48c9399c8a6a358dd29b198f2bd79
treef8233b0f6ff927cfacca346d2bb272f2f2aeb212
parent3b7a4475b0912d6d78c5e2354599dbc8f1ade479
fsmonitor: avoid overriding `cache_changed` bits

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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
fsmonitor.h