From: Steffen Prohaska <prohaska@zib.de>
To: Git Mailing List <git@vger.kernel.org>
Subject: How to update index stat info without reading file content?
Date: Thu, 11 Sep 2014 21:04:08 +0200 [thread overview]
Message-ID: <99C877A8-8145-4D8E-BE83-0F8A1FC16214@zib.de> (raw)
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
next reply other threads:[~2014-09-11 19:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-11 19:04 Steffen Prohaska [this message]
2014-09-11 20:51 ` How to update index stat info without reading file content? Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=99C877A8-8145-4D8E-BE83-0F8A1FC16214@zib.de \
--to=prohaska@zib.de \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.