Hi,

Is there a way to update the stat information recorded in the index without 
reading the file content from disk?

Starting from a clean working copy with a committed `file`, I'd like 

    touch file
    git <magic-command> file

to bring the index into essentially the same state as

    touch file
    git status

but without reading the content of `file`.  (I'd be willing to wait a bit 
between touch and the magic command, to avoid any racy-git-related code paths.)

`git-update-index --assume-unchanged` is related.  But it requires completely 
manual handling of changes, because git will not look at marked files until 
told otherwise with `--no-assume-unchanged`.  I'd like to tell git only that 
the current file content is known to be up-to-date.  Any future changes should 
be handled as usual.

In the documentation, `git add --refresh file` sounds a bit like what I'm 
looking for.  The documentation of `--refresh` states: "Don’t add the file(s), 
but only refresh their stat() information in the index."  But it doesn't do 
what I want.

I looked a bit into `read-cache.c`.  The comment above `refresh_cache_ent()` 
sounds promising:

     "refresh" does not calculate a new sha1 file or bring the
     cache up-to-date for mode/content changes. But what it
     _does_ do is to "re-match" the stat information of a file
     with the cache, so that you can refresh the cache for a
     file that hasn't been changed but where the stat entry is
     out of date.

But it isn't obvious to me whether what I'm looking for is available.  All code 
paths that eventually reach `fill_stat_cache_info()` seem to go through 
`ce_compare_data()` and therefore `index_fd()`, which reads the data from disk.

        Steffen--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to