All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Steffen Prohaska <prohaska@zib.de>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: How to update index stat info without reading file content?
Date: Thu, 11 Sep 2014 13:51:53 -0700	[thread overview]
Message-ID: <xmqqtx4ddgnq.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <99C877A8-8145-4D8E-BE83-0F8A1FC16214@zib.de> (Steffen Prohaska's message of "Thu, 11 Sep 2014 21:04:08 +0200")

Steffen Prohaska <prohaska@zib.de> writes:

> 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.

Yes, "assume-unchanged" is related and it is often abused by
clueless.  The only thing it does is by setting the bit, you promise
Git that the one on the filesystem will be kept the same as the
object recorded in the index forever, one of the implications of
which is that Git is free to use either the version on the
filesystem or data read with read_sha1_file() from the object store,
whichever it finds more convenient, when it needs to read the data
for the object recorded in the index for the path.  You are not
promising the "forever" part, so it is not a good match for what you
are trying to do.

> 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.

No.  It is the same as "update-index --refresh".  You tell it "I've
made this file, which may have had contents different from the
object name recorded in the index before, back to match what is
recorded in the index.", it makes sure that you are not lying, and
then updates the cached stat information so that the next time it
does not have to read the contents.

      reply	other threads:[~2014-09-11 20:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-11 19:04 How to update index stat info without reading file content? Steffen Prohaska
2014-09-11 20:51 ` Junio C Hamano [this message]

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=xmqqtx4ddgnq.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=prohaska@zib.de \
    /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.