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

[PATCH 0/2] update-index: add --refresh-stat-only

From
GGGeorge Giorgidze via GitGitGadget <gitgitgadget@gmail.com>
Date
May 26, 2026, 08:03 UTC
Message-ID
<pull.2125.git.1779782591.gitgitgadget@gmail.com>

This two-patch series adds "git update-index --refresh-stat-only", a one-shot way to update the index's cached stat data to match the current filesystem without rehashing file contents.

When a working tree is produced or restored by means other than a normal checkout -- a CI cache restore, container provisioning, a tarball extraction, or a copy from another machine -- the files may be byte-for-byte identical while filesystem-local stat fields like inode and device numbers no longer match. Today the available workarounds are to (a) pay for full content rehashing on the next "git status", or (b) set core.checkStat=minimal, which is sticky and weakens every subsequent operation. Neither composes well with modern container-based CI, where every job step would otherwise need to set and preserve the configuration.

A similar idea ("--assume-content-unchanged") was discussed in January 2017; see the thread starting at 20170105112359.GN8116@chrystal.oracle.com. The concern raised there was that exposing a way to update cached stat data without content comparison opens the index to abuse. The flag in this series is deliberately narrower than the 2017 proposal:

 * one-shot action, not a sticky config or per-entry bit;
 * the name describes what the invocation does, not a trust state attached
   to entries (contrast --assume-unchanged);
 * intended for closed-loop callers (CI cache restore, container
   provisioning, backup/restore tooling) that produced or verified the
   worktree atomically;
 * the failure mode -- stale object IDs becoming invisible until the next
   content check -- is named directly in the docs, and the flag must be
   typed explicitly.
The series is organised so the bug fix is reviewable on its own:
1/2 preload-index: respect --really-refresh override of assume-unchanged
   A latent bug observable today via GIT_TEST_PRELOAD_INDEX=1:
   preload_thread() never sets CE_MATCH_IGNORE_VALID, so it
   honours the "assume unchanged" bit and marks modified
   assume-unchanged entries as uptodate before the
   --really-refresh loop sees them. Plumb refresh flags
   through to preload threads and add a regression test under
   t2106.
2/2 update-index: add --refresh-stat-only
   Add the new flag, extend the preload mask to also recognise
   REFRESH_STAT_ONLY, document the assume-unchanged override
   behaviour alongside the flag, and add coverage for object
   ID preservation, missing-file handling (with and without
   --ignore-missing), assume-unchanged override, and quiet
   output under t2109.
George Giorgidze (2):
  preload-index: respect --really-refresh override of assume-unchanged
  update-index: add --refresh-stat-only
 Documentation/git-update-index.adoc       | 19 ++++++++
 builtin/update-index.c                    | 12 +++++
 preload-index.c                           |  7 ++-
 read-cache-ll.h                           |  3 ++
 read-cache.c                              | 24 +++++----
 t/meson.build                             |  1 +
 t/t2106-update-index-assume-unchanged.sh  | 11 +++++
 t/t2109-update-index-refresh-stat-only.sh | 59 +++++++++++++++++++++++
 8 files changed, 126 insertions(+), 10 deletions(-)
 create mode 100755 t/t2109-update-index-refresh-stat-only.sh
base-commit: 56a4f3c3a221adf1df9b39da69b8a6890f803157
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2125%2Fgiorgidze%2Fmaster-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2125/giorgidze/master-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/2125
-- 
gitgitgadget
Next: George Giorgidze via GitGitGadget
Message 1 of 3 in “update-index: add --refresh-stat-only”
  1. 0/2 update-index: add --refresh-stat-onlyGeorge Giorgidze via GitGitGadget, May 26, 2026
  2. 1/2 preload-index: respect --really-refresh override of assume-unchangedGeorge Giorgidze via GitGitGadget, May 26, 2026
  3. 2/2 update-index: add --refresh-stat-onlyGeorge Giorgidze via GitGitGadget, May 26, 2026

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.